def create
@feedback = Feedback.new(params[:feedback])
if logged_in?
@feedback.user_id = current_user.id
end
if @feedback.valid?
FeedbackMailer.deliver_feedback(@feedback) if !@feedback.email.blank?
@feedback.save
render :status => :created, :text => '<h3>Thank you for your
feedback!</h3>'
else
@error_message = "Please enter your #{@feedback.subject.to_s.downcase}"
render :action => 'new', :status => :unprocessable_entity
end
end
validation is only on one field, which has a value in the params-hash.
model-validations etc are all the same - locally vs server
Well, that’s the top of the stack-trace but the actual exception and its message is?
the create method is basically this:
def create
@feedback = Feedback.new(params[:feedback])
if logged_in?
@feedback.user_id = current_user.id
end
if @feedback.valid?
FeedbackMailer.deliver_feedback(@feedback) if !..@feedback.email.blank?
@feedback.save
render :status => :created, :text => ‘
Thank you for your
feedback!
’
else
@error_message = “Please enter your #…@feedback.subject.to_s.downcase}”
render :action => ‘new’, :status => :unprocessable_entity
end
end
validation is only on one field, which has a value in the params-hash.
model-validations etc are all the same - locally vs server
any ideas?
Well, since the code in your action looks simple enough and since we know the error is raised on the @feedback.save call, then I’d focus on why it can’t save. The upshot is that we need more info to help you. What were the values submitted to the action (in the params hash) by the request that failed? What was the actual exception and error message (it’s nice you provided stack trace but we need this too). What is this validation’s code, the one you said the model has “on one field”? What else might be different in your environment between your development and staging production? Does it succeed in production mode on your dev workstation, meaning the problem is specific to where it’s deployed, not the mode? Or, does it always fail in production, regardless of where it’s deployed?
Processing FeedbacksController#create (for 78.42.xyz.xyz at 2011-05-20
09:26:51) [POST]
Parameters: {"commit"=>"Send",
"authenticity_token"=>"2HzCbBM0J1SfEwIHP/GucR+HPs3fM31ts69llwkQDNc=",
"feedback"=>{"comment"=>"test", "subject"=>"Suggestion",
"email"=>"myemail@gmail.com"}, "_"=>""}
Sent mail to tom@foobar.com
The clue is in the error message. At the above line you are
presumably calling delete, though that seems a bit odd in create. The
object you are calling delete on is nil.
yes and no - im not calling delete 'manually' nor do i have coded it
into the create method. to me it seems the rollback is doing this, as
far as i can trace back the code.
anyhow - thx