Haml syntax problem

why is it not haml valid syntax

= form_tag(media_path(place_id: @place) , :multipart => true)  do
  = label_tag :image , "Place image"
  = file_field_tag :image
  = submit_tag "submit new comment"

      

Exception on line 46: compilation error /.../show.html.haml:46: syntax error, unexpected ':', expecting ')' ... form_tag (media_path (place_id: @place) ,: multipart => true ) ... ^ Use --trace for backtrace. Use -trace for backtrace.

+3


source to share


3 answers


try: place_id => @ place.id The error can also be if you use @place instead of @ place.id



+2


source


check the place object first and fix it with something like

= form_tag(media_path(:place_id => @place) , :multipart => true) do



Abandoning the code

= form_tag(:url => media_path(:object_id =>@object),:html => {:class=> "form"} ) do

+1


source


Actaully both failed to notice that you are using the ruby ​​1.9.2 syntax along with the old 1.8.7 syntax style. I am assuming that you are trying to use this form with an application running on 1.8.7, which is why it is giving you a compilation error. If you are using ruby-1.9.2 you will not get this compilation error. In ruby-1.9.2, you can declare a Javascript json style hash. ie {username: 'John'}

So either you are using ruby-1.9.2 or change (place_id: @place) to (: place_id => @place)

+1


source







All Articles