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
Post a Comment