I'm using Rails 3, and I have a form_for in a StatusController. When I hit the submit button, my create method is never called. My create method has a redirect_to :index, however when I hit submit all of the information remains in the form, and the page does not redirect. The object does save correctly in the database however.
What would be causing this?
Controller:
class StatusController < ApplicationController
def new
@status = Status.new
end
def create
@status = Status.new(params[:status])
@status.date_added = Time.now
if @status.save
else
render 'new'
end
end
View:
.well
=form_for @status do |f|
=f.label :user_email
=f.text_field :user_email
=f.label :added_by
=f.text_field :added_by
=f.label :comments
=f.text_area :comments
%br
%br
=f.submit
I've adjusted the code to this, and now the data disappears from the form upon a submit, however the object never gets saved because "Create" is never invoked.
resources :statusesin your routes.rb? - cdesrosiers