I have a small problem and it is really bugging me.
I have all the standard scaffold code in the controllers to give me the standard CRUD features.
The collection_select form helper is in my view:
<%= collection_select(:link,:category_id,@categories,:id,"name") %>
The Link Table has a category_id column. This is being posted ok, as while debugging it gives:` ... "link"=>{"name"=>"", "category_id"=>"1", ...
However it is not being submitted to the database and any validation of the category_id fails.
Controller Methods:
def new
@link = Link.new
@categories = Category.find(:all)
end
def create
@link = Link.new(params[:link])
if @link.save
flash[:notice] = "Successfully created link."
redirect_to @link
else
render :action => 'new'
end
end
Form from View
<% form_for @link do |f| %>
<%= f.label :name %><br />
<%= f.text_field :name %>......