Colin Law wrote in post #1065643:
> On 21 June 2012 22:58, renu mehta <li...@ruby-forum.com> wrote:
>
> Please quote the previous message when replying, it makes it easier to
> follow the thread.  Remember that this is an email list not a forum
> (though you may be accessing it through a forum.  Thanks.
>
>> NoMethodError (undefined method `member_phones' for
>> #<Member:0x000000022d3938>):
>> app/controllers/home_controller.rb:43:in `member'
>
> Please post the code of member.rb and member_phones.rb (snip out any
> irrelevant methods that may be there).  Also the code from
> home_controller around the error.  Thanks.
>
> Colin

home_controller
     def member

    @member = Member.new
    @member.family_id = random_number(5)
    @member_id=random_number(6)
    @member_phone=@member.member_phones.build
     end


And the view member.html.erb has :

<label>
                 <span>Home : </span>
              <%= text_field "member_phone", "home_phone", :class => 
"input_text" %>

             </label>


class MemberPhone < ActiveRecord::Base

  belongs_to :member, :foreign_key => "member_id"

end


class Member < ActiveRecord::Base
  alias_attribute :family_member_id, :member_id

  has_many :member_addresses , :foreign_key => "family_member_id"

  has_many :member_phones , :foreign_key => "family_member_id"



  accepts_nested_attributes_for :member_addresses
  accepts_nested_attributes_for :member_phones


end

-- 
Posted via http://www.ruby-forum.com/.

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

Reply via email to