Forum: Ruby on Rails erubis on rails

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Mark D. (Guest)
on 2006-12-22 22:06
Hey,

Just thought I'd see how easy it was to use erubis rather than erb in
rails, and so far all seems to be pretty easy. Just added a few lines in
environment.rb and everything works as before.

However, one page is causing a problem. It is a partial that is being
passed a local variable. erubis doesn't seem to see the local, and gives
the following error?

  undefined local variable or method `page' for
  #<Erubis::Helper::RailsTemplate:0x27557fc>

Even though the partial is being rendered from another page with the
following statement:

  <%= render :partial => 'node', :locals => { :page => @home_page } %>

Any ideas how you can pass a local to a partial when using erubis?

Thanks,

Mark
RSL (Guest)
on 2006-12-23 20:42
There's already a patch put in for it.
http://rubyforge.org/tracker/index.php?func=detail...
But it doesn't look like anyone official has looked at it or anything. I
applied the patch and voila! It works! Hope you get the same result.

RSL

Mark D. wrote:
> Hey,
>
> Just thought I'd see how easy it was to use erubis rather than erb in
> rails, and so far all seems to be pretty easy. Just added a few lines in
> environment.rb and everything works as before.
>
> However, one page is causing a problem. It is a partial that is being
> passed a local variable. erubis doesn't seem to see the local, and gives
> the following error?
>
>   undefined local variable or method `page' for
>   #<Erubis::Helper::RailsTemplate:0x27557fc>
>
> Even though the partial is being rendered from another page with the
> following statement:
>
>   <%= render :partial => 'node', :locals => { :page => @home_page } %>
>
> Any ideas how you can pass a local to a partial when using erubis?
>
> Thanks,
>
> Mark
Russell N. (Guest)
on 2006-12-23 23:11
(Received via mailing list)
I just ran across the same error without even calling the local from the
partial itself. It seems like just creating the local raises the error.

Oh fun! A bug to fix for Christmas! Yay!

RSL
This topic is locked and can not be replied to.