views:

35

answers:

1

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 somehow, 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.

+1  A: 

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

Slobodan Kovacevic
Oh! You're right. I somehow thought you could close access level declarations like a block with an end, and I thought I did so, but neither of those things are true. That would make perfect sense.
RyanG