Ruby on Rails Wednesday, May 30, 2012

I have simple problem with overriding attribute readers and seeing same changes appear on simple_form. I have a model and it has some attributes that I want to override with different readers. I did something like following

class CustomerSupplierItem < ActiveRecord:Base

  # it has attribute called pack

  def pack
    "Some overridden value"
  end

end

Now when I use the model in simple_form

<%= simple_form_for @customer_supplier_item do |f| %>
  <%= f.input :pack %>
<% end %>

I do not get "Some overridden value" as value in pack input. I see original pack value without overridden attr_reader.

What is the way to override the attr_reader such that is affects simple_form and similar form helpers?

Regards
Amit

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/d3abKTt41K4J.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

No comments:

Post a Comment