Saturday, January 19, 2013

[Rails] Re: Get vars out of Controller

Javier Quarite wrote in post #1092882:
> On Sat, Jan 19, 2013 at 6:44 PM, Pierre-Andre M.
> <lists@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
>>
>>
> That variable only works on that method, you need an instance variable
>
> def calendar
> @my_time = Time.now
> end
>
> in view calendar.html.erb
>
> <%= @my_time%>

That worked awesome thanks a bunch...also, I appreciate the follow up
dialogue on using different methods as well...Im sure I'll appreciate
this more once I'm more well-versed.

--
Posted via http://www.ruby-forum.com/.

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate