Reputation: 4459
I need to switch forms declaration in HAML.
- if params[:action] == 'tomato'
= form_for @request, :url => 'request/tomato' do |f|
- else
= form_for @request do |f|
= f.text_field ... # form content
= f.text_field # don't work too
But i can't use end
to separate form declaration from form content, so i get 500 internal server error
How can i achieve this?
Upvotes: 0
Views: 2823
Reputation: 11628
Try this
- args = params[:action] == "tomato" ? {:url => 'request/tomato'} : {}
= form_for @request, args do |f|
= f.text_field :field_one
= f.text_field :field_two
Upvotes: 3
Reputation: 157
Since Haml works on indentation, you don't need an End statment after an If.
Make sure your 'if' and 'else' are aligned and put any content that should come after at the correct indentation.
Upvotes: 2