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.
Df6805f12a6120f840e218fd883958a6?d=identicon&s=25 Mark Dodwell (mkdynamic)
on 2006-12-22 21: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
5030981121b21bed8aee074f68bd5074?d=identicon&s=25 RSL (Guest)
on 2006-12-23 19: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 Dodwell 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
70225136eacd3d870f64e03bff678655?d=identicon&s=25 Russell Norris (Guest)
on 2006-12-23 22: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.