Newbie question
URL:
/categories/new?parent_id=6
Controller:
def new
@category = Category.new( :parent_id => params[ :parent_id ] )
end
View:
<%= form_for( @category ) do |f| %>
<%= f.hidden_field :parent_id %>
<% end %>
Source of the page:
<input id="category_parent_id" name="category[parent_id]" type="hidden" />
Why isn’t the value being passed through?
EDIT: I realized after that I didn’t have :parent_id as part of my attr_accessible in my model Category. Everything’s working as it should now. Thanks for the help guys.
EDITED after @Ceilingfish wise remark
Try this: