37

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.

the Tin Man
  • 158,662
  • 42
  • 215
  • 303
ssri
  • 1,290
  • 4
  • 15
  • 23

2 Answers2

81

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 }
Pravin
  • 6,592
  • 4
  • 42
  • 51
15

You would use the :locals option if you're calling render from a controller. When calling render from a view, you would simply do this:

= render 'meeting_info', :info => @info
the Tin Man
  • 158,662
  • 42
  • 215
  • 303
dearlbry
  • 3,193
  • 2
  • 23
  • 23