Remote form in popover processing as html

Im trying to submit a rails remote form in a bootstrap popover, but it keeps processing as html. There are no js errors, controller responds to js and i have a create.js.erb. Can someone please point me to the problem?

Below is the content of my popover. Users have to options when submitting a form - in order to make it faster for the user, i made two forms so the user can choose an option and submit by clicking only one button.

POPOVER CONTENT:

<%= form_for @event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => ‘option1’, :room_id => current_block.loundry.room_id), :remote => true do |f| %>

<% if f.object.errors.any? %>

<%= pluralize(f.object.errors.count, "error") %> evitaron que se guardara esta actividad:

    <% f.object.errors.full_messages.each do |msg| %>

  • <%= msg %>
  • <% end %>

<% end %>

<%= f.hidden_field :owner_id %>

<%= f.hidden_field :start_at %>

<%= f.hidden_field :end_at %>

<%= f.hidden_field :all_day %>

<%= f.hidden_field :room_id %>

<%= f.hidden_field :title %>

<%= f.hidden_field :description %>

<%= f.hidden_field :frequency %>

<%= f.submit ‘Option1’, id: option1_icon_link’%>

<% end %>

<%= form_for @event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => ‘option2’, :room_id => current_block.loundry.room_id), :remote => true do |f| %>

<% if f.object.errors.any? %>

<%= pluralize(f.object.errors.count, "error") %> evitaron que se guardara esta actividad:

    <% f.object.errors.full_messages.each do |msg| %>

  • <%= msg %>
  • <% end %>

<% end %>

<%= f.hidden_field :owner_id %>

<%= f.hidden_field :start_at %>

<%= f.hidden_field :end_at %>

<%= f.hidden_field :all_day %>

<%= f.hidden_field :room_id %>

<%= f.hidden_field :title %>

<%= f.hidden_field :description %>

<%= f.hidden_field :frequency %>

<%= f.submit ‘Option2’, id: ‘option2_icon_link’%>

<% end %>

Im trying to submit a rails remote form in a bootstrap popover, but it keeps processing as html. There are no js errors, controller responds to js and i have a create.js.erb. Can someone please point me to the problem?

Below is the content of my popover. Users have to options when submitting a form - in order to make it faster for the user, i made two forms so the user can choose an option and submit by clicking only one button.

POPOVER CONTENT: <div id="booking_dialog">   <div id="calendar_form" class="booking_dialog_content">

    <%= form_for @event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => 'option1', :room_id => current_block.loundry.room_id), :remote => true do |f| %>

I'm going out on a limb here, but I think it's doing something with the precedence of || in your first bit. Try wrapping the @event || Event.new in parens and see what happens?

<%= form_for (@event || Event.new(:owner_id => current_block.actor_id, :interval => 1, :title => 'option1', :room_id => current_block.loundry.room_id)), :remote => true do |f| %>

Niiiiiiice! that did it, thanks!

I think it might be even nicer to setup @event in the controller. It is generally better to keep such code out of the view.

Colin

you’re right, thanks