Saturday, January 19, 2013

Re: [Rails] Get vars out of Controller


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%>


----------------------------
Javier

--
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