ruby - Creating a global variable to all the controllers in Rails -


i have base url common controllers. want declare variable in 1 place, , use in controllers. make future updates fast , simple. possible? i'm declaring in controllers this:

@baseurl = "www.url.com/something/" 

take advantage of ruby's inheritance chain. can define on parent class of controllers constant, applicationcontroller:

class applicationcontroller < actioncontroller::base   base_url = "www.url.com/something/" end 

then become available children, namely postscontroller < applicationcontroller.


Comments

Popular posts from this blog

Receive udp packets in android gstreamer -

php - Extract Text from HTTP referer -

java - Callback from new thread to class from which thread was initiated -