I have my articles migration create_table :articles do |t| t.integer :category_id, :null => false etc.. and my form Select a category <%= f.select :category_id, Category.all.collect {|category| [category.name, category.id ]} %> But everytime im sending that info im getting a nil value for category_id -- 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.
I''m assuming the problem happens when creating new records. Can we see the new and create actions in your controller and the full form in the view? Also, are there any before/after/around filters and/or callbacks that could be affecting the behavior of the application? On May 10, 8:19 pm, "Tomas R." <li...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have my articles migration > > create_table :articles do |t| > t.integer :category_id, :null => false > etc.. > > and my form > > Select a category > <%= f.select :category_id, Category.all.collect {|category| > [category.name, category.id ]} %> > > But everytime im sending that info im getting a nil value for > category_id > > -- > Posted viahttp://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@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 11 May 2011 01:19, Tomas R. <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> I have my articles migration > > create_table :articles do |t| > t.integer :category_id, :null => false > etc.. > > and my form > > Select a category > <%= f.select :category_id, Category.all.collect {|category| > [category.name, category.id ]} %> > > But everytime im sending that info im getting a nil value for > category_idFirst look in development.log to see if it is being passed with the request ok. Then use ruby-debug to break into your code in the controller action (create or update presumably) and you can inspect the data to work out where it is getting lost. See the Rails Guide on debugging to find how to do that. 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.
This could be that you are trying to assign attributes that are protected from mass assignment. Try adding: attr_accessible :category_id ..to your article model. -- 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.