Rendering partial with locals in Haml?

ssri picture ssri · Mar 10, 2011 · Viewed 41.6k times · Source

I am learning Haml.

My view files are like:

show.html.haml:

.content
  = render 'meeting_info', :locals => { :info => @info }

and _meeting_info.html.haml:

.detail
  %table
    %caption
      Meeting Informations of
      = info["meeting_name"]
...

When I tried running this I got an undefined local variable or method 'info' error.

Answer

Pravin picture Pravin · Mar 10, 2011

Try this
Without :locals and :partial

.content
  = render 'meeting_info', :info => @info

No need to specify locals.

With :locals and :partial
You should specify locals in following case i.e specifying :partial for render

.content
  = render :partial => 'meeting_info', :locals => { :info => @info }