开发者

Troubleshooting: Rails can't save to database in production?

I could use a little help trouble shooting this problem.

When using the app to create a new record nothing is being saved to the database. There are no visible errors presented.

Dropping to the command line, and using the console with the same production environment, I can create a new object and save it (I have to bypass validations). If I look in mysql database I can see the record that I created from the console.

开发者_C百科App works fine locally.

Any thoughts on what might be the problem?

Rails 2.0.2


Sounds like a validation error.

In your controller, try using save! (with the bang) to see if will throw a meaningful error.

I am not sure what code you have in the controller, but this might help show the problem

if my_object.save
  log.debug 'object saved correctly'
else
  log.debug my_object.errors.full_messages
end

Good luck, if this doesn't help. Try posting the relevant controller and model code.


Have you double checked that the request (with params, etc) works correctly in development?

If not, perhaps looking at the production log file will tell you where the request was routed (e.g. which controller and action, and with which parameters).

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜