Hello, In my app there is a one-to-many relation between members and member_phones. Following code works in ruby 1.8.7, rails 3.0.3 but fails on heroku. @member = Member.new @member_phone=@member.member_phones.build but this works on heroku: @member = Member.new @member_phone=MemberPhone.new But this way I have specify @member_phone.save! otherwise it is not saved in database. Now, my problem is that if thats the way I have to go then , how do I create a collection/hash/array of member_phones so that I can accept mutliple member_phones on the view. Again a problem here as I can''t use formtastic gem because for one it would require a lot of custom styling and I already have an application template for the whole application that I have to use. And , also the hosting service which I may end up finally end up to host my app will not allow any gems installation. Therefore, I am stuck with default setup and javascript/jquery use to customise my views. Thanks. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2012 18:50, renu mehta <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Hello, > > In my app there is a one-to-many relation between members and > member_phones. > Following code works in ruby 1.8.7, rails 3.0.3 but fails on heroku. > > > @member = Member.new > @member_phone=@member.member_phones.buildIn what way does it fail? Colin -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
NoMethodError (undefined method `member_phones'' for #<Member:0x000000022d3938>): app/controllers/home_controller.rb:43:in `member'' Thats the error that I get. -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 21 June 2012 22:58, renu mehta <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 -- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.
Colin Law wrote in post #1065643:> On 21 June 2012 22:58, renu mehta <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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. > > Colinhome_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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 22 June 2012 17:28, renu mehta <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> Colin Law wrote in post #1065643: >> On 21 June 2012 22:58, renu mehta <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 > -IGUgQLVVQiTwMemgg8S7EQ@public.gmane.org_id = random_number(5) > @member_id=random_number(6) > @member_phone=-boRHYbzXHqmWqOXvAXkSaA@public.gmane.org_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"The foreign_key spec here is not required as member_id is the default. It should not do any harm however.> > end > > > class Member < ActiveRecord::Base > alias_attribute :family_member_id, :member_idWhat is the purpose of the above line? Does the members table have a column with one of those names? If so, why?> > has_many :member_addresses , :foreign_key => "family_member_id" > > has_many :member_phones , :foreign_key => "family_member_id"The above line says that member_phones (not members) has a column family_member_id. Has it? Colin> > > > accepts_nested_attributes_for :member_addresses > accepts_nested_attributes_for :member_phones > > > end-- 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-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org 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.