开发者

ActiveRecord::Base.new returning nil

For some reason, one of my models in rails is returning nil when I call .new. This is only a problem in the controller. When I try on the console, it returns an object with nil attributes as I would expect. I suspect the problem is in my controller, but I have no idea.

This also happens when I call .all. Again, I can execute these commands manually from the command line without issue.

Here's the controller code:

http://gist.github.com/502816

EDIT: Looks like a few of my other models are acting the same way. This problem is clearly deeper than this controller/model. I'm still very new to rails, so I'm not sure where to look to debug this.

EDIT2: A wise friend of mine helped me figure out that the controller action isn't even being called. My before filter, however, is, but it is not redirecting. So someh开发者_如何学运维ow, the right controller is found, but the appropriate action isn't called.

My server log SAYS the right action is being processed, but the actual function body doesn't seem to execute.


I think your problem is that all of your methods EventsController are declared to be private. Private methods cannot be called as actions - so you are having problems.

Try to move private declaration and redirect_if_not_logged_in to the end of the file, i.e. after the destroy method.

For more information how public/private/protected work in Ruby read this: http://www-users.math.umd.edu/~dcarrera/ruby/0.3/chp_04/features.html

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜