Best way to set custom Controller options

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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs