I want to upload file with javascript AJAX but I have an error InvalidAuthenticutyToken when I correct my code like I see on many website another error appear : Unknown format
in :
if @personal.save
format.js
end
In my IDE the .js
do an error : cannot find js
I think I miss a gem. My installed gems in order to use javascript are :
gem 'coffee-rails', '~> 4.1.0'
gem 'coffee-script-source', '1.8.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
And my form is
<%= bootstrap_form_for @personal, :html => {:multipart => true}, :remote => true do |f| %>
<div class="modal-body">
<%= f.text_field :trigramme, label: "Trigramme" %>
<%= f.text_field :nom, label: "Nom" %>
<%= f.text_field :prenom, label: "Prenom" %>
<%= f.text_field :poste, label: "Poste" %>
<%= f.text_field :arrivee, label: "Arrivee a OCTO" %>
<%= f.text_area :bio, label: "Bio", :rows => "5" %>
<%= f.file_field :img, label: "Photo" %>
</div>
<div class="modal-footer">
<%= f.submit class: "btn btn-primary" %>
<%= link_to "Cancel", "#", class: "btn", data: {dismiss: "modal"} %>
</div>
It's weird because when I have the error of Invalid AuthenticutyToken my image is correctly uploaded in database but I have the error. I have some js.erb
file that print a popup with the form. I have tried remotipart but nothin happen I have again the error.
Do I miss a gem in order to use javascript due to second error unknownFormat
? What is my problem ? Do you have a clue?
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire