Hi. I have a form in my app which, for some reason is not saving any
objects to the database. After clicking submit it redirects back to
itself, but it dosent give any information as to what is going wrong.
Hi. I have a form in my app which, for some reason is not saving any
objects to the database. After clicking submit it redirects back to
itself, but it dosent give any information as to what is going wrong.
We would need to see the code for your 'create' action in your auctions_controller.rb
respond_to do |format|
if @item.save
flash[:notice] = 'Item was successfully created.'
format.html { redirect_to(@item) }
format.xml { render :xml => @item, :status => :created, :location => @item }
else
format.html { render :action => "new" }
format.xml { render :xml => @item.errors, :status => :unprocessable_entity }
end
end
end
Everything looks good there. You said it's redirecting back on itself. I assume you mean that it's going back to the 'new' action, which is what you have it doing if the save fails (which is good). So, make sure you have the following in your new.html.erb file...
<%= error_messages_for :auction %>
That should hopefully give you a hint why the save is failing. Probably some validations you have setup that aren't passing.