Reputation: 21573
I'm using _form
both in index
and edit
. The problem is that, in index
, it's a remote form, and in edit
, I want it to be an ordinary form.
Perhaps something like
= form_for post, remote: true if params[:action] != 'edit' , html: { class: 'post-form' } do |f|
How can I do that?
Upvotes: 2
Views: 508
Reputation: 2575
Try like this
= form_for post, ({ remote: true } if params[:action] == 'edit') do |f|
Upvotes: 0
Reputation: 38645
Here is a slightly different syntax:
= form_for post, remote: (action_name == 'index'), html: { class: 'post-form' } do |f|
You just want either remote: true
or remote: false
.
Upvotes: 2
Reputation: 21573
This is what I end up with: When calling
= render 'posts/form', post: @post, remote_control: false
And in _form
- remote_control = true if remote_control.nil?
= form_for post, remote: remote_control , html: { class: 'post-form' } do |f|
Upvotes: 0