Abdulaziz Alsubaie
Abdulaziz Alsubaie

Reputation: 720

haml syntax issue

why this is 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: compile 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.

Upvotes: 3

Views: 680

Answers (3)

hbdev012
hbdev012

Reputation: 630

Actaully both didn't noticed that you are using ruby 1.9.2 hash syntax along with old 1.8.7 syntax style. I assume that you are trying to use this form with application running on 1.8.7, thats why it is giving you compile error. If you use ruby-1.9.2 you will not get that compile error. In ruby-1.9.2 you can declare you hash in Javascript json style. i.e {username: 'John'}

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

Upvotes: 1

Arpit Vaishnav
Arpit Vaishnav

Reputation: 4780

first of all check the object of place and correct it to something like

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

Refrence like code

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

Upvotes: 1

gayavat
gayavat

Reputation: 19418

try :place_id => @place.id Error may be also if you use @place instead @place.id

Upvotes: 2

Related Questions