[Rails] Re: Getting null value when it's assigned

2011-05-12 Thread joshnesbitt
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@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.



[Rails] Re: Getting null value when it's assigned

2011-05-11 Thread pepe
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...@ruby-forum.com 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@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.