Forum: Ruby on Rails Best way to set custom Controller options

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Marco L. (Guest)
on 2006-04-04 00:33
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
Jon B. (Guest)
on 2006-04-04 02:23
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 topic is locked and can not be replied to.