Get vars out of Controller

I have a trivial question:

if i have defined something in my controller, like

def calendar     my_time =


how do I use that variable in my view?

I tried <%= my_time %>

But that simply returns an error.


That variable only works on that method, you need an instance variable

def calendar   @my_time = end

in view calendar.html.erb

<%= @my_time%>

Hello Pierre

You could either use an instance variable like this:

@my_time =

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.

Because attr_accesor doesn't exist, so the entire premise isn't broken o.O. /end-broken-logic

helper_method :calendar Is what you want.

It’s a good gem but it’s a bit heavy handed since it (nicely) provides and, iirc, wraps helper_method.

Javier Quarite wrote in post #1092882:

I suggest that you work right through a good rails tutorial such as, which is free to use online, which will show you the basics or Rails. Make sure that any tutorial you use is for rails 3 and that you install the correct version of rails for the tutorial.