Eamonn M.R.
Eamonn M.R.

Reputation: 2037

Routing / Unknown action

I have a route pointing to a method in controller like:

match foo/bar => bar#qux

When I have an instance method called qux, it seems to be finding the controller alright, because it (correctly, I think) complains that there's no such method (because it's supposed to be static).

When I have a static method self.qux in bar, however, it tells me:

Unknown action

The action 'qux' could not be found for Bar

Upvotes: 0

Views: 51

Answers (1)

user229044
user229044

Reputation: 239322

Your controller's actions must be instances methods. Rails will spawn an instance of your controller and attempt to invoke the given method on it.

def self.qux should simply be def qux.

Upvotes: 2

Related Questions