I use the simple_form pearl and generate the form. I specify the remote: true parameter as follows:
<%= simple_form_for @webinar, validate: true, remote:true do |f| %>
So, the html output for the form is the following snippet:
<form accept-charset="UTF-8" action="/webinars" class="simple_form new_webinar" data-remote="true" data-validate="true" enctype="multipart/form-data" id="new_webinar" method="post" novalidate="novalidate"> ... </form>
As I checked, using the standard form_for helper, data-remote = 'true' is added to the form when remote: true is used. And as you can see from the generated html, when I use simple_form pearls, there is such an attribute.
So, in my controller, I:
def create @webinar = Webinar.new(params[:webinar]) respond_to do |format| if @webinar.save format.html { redirect_to @webinar, notice: 'Webinar was successfully created.' } format.js format.json { render json: @webinar, status: :created, location: @webinar } else format.html { render action: "new" } format.json { render json: @webinar.errors, status: :unprocessable_entity } end end end
But format.html is always used. What am I doing wrong?
EDIT:
I used logger.debug request.format to check what the actual format for the log file and in its file is:
text / html
So, the problem should be in the generated simple_form form - what could be wrong there when we have "data-remote = true"?
gotqn
source share