[Rails] Get vars out of Controller

2013-01-19 Thread Pierre-Andre M.
I have a trivial question: if i have defined something in my controller, like def calendar my_time = Time.now end how do I use that variable in my view? I tried %= my_time % But that simply returns an error. Thanks -- Posted via http://www.ruby-forum.com/. -- You received this

Re: [Rails] Get vars out of Controller

2013-01-19 Thread Javier Quarite
On Sat, Jan 19, 2013 at 6:44 PM, Pierre-Andre M. li...@ruby-forum.comwrote: I have a trivial question: if i have defined something in my controller, like def calendar my_time = Time.now end That variable only works on that method, you need an instance variable def calendar

Re: [Rails] Get vars out of Controller

2013-01-19 Thread Benjamin Iandavid Rodriguez
Hello Pierre You could either use an instance variable like this: @my_time = Time.now Then in your view access it with: %= @my_view % Or use the decent_exposure gem which I recommend since this lets you access your variables without exposing instance variables in the view context. 2013/1/19

Re: [Rails] Get vars out of Controller

2013-01-19 Thread Jordon Bedwell
On Sat, Jan 19, 2013 at 6:13 PM, Benjamin Iandavid Rodriguez ian@gmail.com wrote: Or use the decent_exposure gem which I recommend since this lets you access your variables without exposing instance variables in the view context. Because attr_accesor doesn't exist, so the entire premise

Re: [Rails] Get vars out of Controller

2013-01-19 Thread Johnneylee Rollins
helper_method :calendar Is what you want. On Jan 19, 2013 6:44 PM, Pierre-Andre M. li...@ruby-forum.com wrote: I have a trivial question: if i have defined something in my controller, like def calendar my_time = Time.now end how do I use that variable in my view? I tried %=

Re: [Rails] Get vars out of Controller

2013-01-19 Thread Johnneylee Rollins
It's a good gem but it's a bit heavy handed since it (nicely) provides and, iirc, wraps helper_method. On Jan 19, 2013 7:20 PM, Jordon Bedwell envyge...@gmail.com wrote: On Sat, Jan 19, 2013 at 6:13 PM, Benjamin Iandavid Rodriguez ian@gmail.com wrote: Or use the decent_exposure gem which