[Rails] Action Variables Not Available In The View For A Specific Action

Jeff Ward
Wed, 10 May 2006 17:30:52 -0000

I am setting an action variable in my PagesController such as:

def manage
  render(:layout => "admin")
  @strOut = "STRING Variable Set From The MANAGE Action!"
end

And in the /views/pages/manage.rhtml view, I don?t have access to that
@strOut variable by trying to call it as: <%= @strOut %>

However, I am setting the same variable in another action in the controller
such as:

def view
  @strOut = "STRING Variable Set From The EDIT Action!"
end

... and I have full access to it in /views/pages/view.rhtml

The only difference in the actions being this:
render(:layout => "admin") ...in the manage action.

So, I want the manage action to use /views/layouts/admin.rhtml, and the edit
action to use /views/layouts/pages.rhtml.

I''m not sure if the layouts have anything to do with it but I really
don''t
know why that variable cannot be called from the view.

--
?
Jeff
?