I have a form that shoul开发者_如何学God use "remote => true" when it's updating a record, but not when creating a new one.
I tried:
<%= form_for position position.new_record? ? (, :remote => true do) |p| %>
syntax error...
To fix your example:
<%= form_for position, (position.new_record? ? {} : {:remote => true}) do |p| %>
But to make it a bit nicer you could do this:
<%= form_for position, :remote => position.new_record? do |p| %>
精彩评论