Best way to set custom Controller options


#1

Hi All!

I’m searching a good way to set some options in my Controllers; I tried
defining a custom function, ie:

class PeopleController < ApplicationController
set_my_actions :action1, :action2
end

class ApplicationController
def self.set_my_actions(*args)
@@my_actions = args
end
end

But ‘@@my_actions’ sets the class variable to every Controllers
classes!

Any hints?

Thanks,
Marco


#2

Maybe I don’t understand what you want to do. What’s wrong with just:

class ApplicationController
def foo # every controller has “foo” action
end
end

class PeopleController < ApplicationController
def bar # only people controller has “bar” action
end
end

Marco L. wrote:

Hi All!

I’m searching a good way to set some options in my Controllers; I tried
defining a custom function, ie:

class PeopleController < ApplicationController
set_my_actions :action1, :action2
end

class ApplicationController
def self.set_my_actions(*args)
@@my_actions = args
end
end

But ‘@@my_actions’ sets the class variable to every Controllers
classes!

Any hints?

Thanks,
Marco