I am trying to show the value of an attribute via its id with formtastic. I have two models hat are setup like this
class Membership < ActiveRecord::Base
has_many :members
attr_accessible :membership_type
end
class Member < ActiveRecord::Base
belongs_to :membership
accepts_nested_attributes_for :membership
attr_accessible :membership_id, :forename, :middlename, :surname, :house_no, :house_name, :street, :town, :postcode, :home_tel, :mobile_tel, :work_tel, :email
end
My index view is set up like this so far
index do
column :forename
column :middlename
column :surname
column :house_no
column :house_name
column :street
column :town
column :postcode
column :home_tel
column :mobile_tel
column :work_tel
column :email
column :membership
default_actions
end
but the value for the membership is output as
#<Membership:0x007f2c2064c370>
How would i get the actual value so it will say "Student" for example
Normally i would do something like this i guess
<% @members.each do |m| %>
<%= m.forname%>
<%= m.surname%>
<% m.memberships.each do |s| %>
<%= s.membership_type%>
<% end %>
but cant figure it out within formtastic
Thanks
Try this: