简体   繁体   中英

To Ruby on Rails - authenticity_token does not work


I'm a beginner programmer on Ruby on Rails.
I have a form that adds an object with attached. The file is stored on the cloud from Amazon S3.
Form done through javascript using ujs. In the form of added parameter: remote: true . But saving does not occur, and there is an error:
Missing template cards/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :slim]}.
Help what to do?

my form:

  = simple_form_for [@deck, @card], remote: true, authenticity_token: true do |f|
    p
      = f.input :original_text, as: :string, label: 'Original text', input_html: { class: 'form-control' }
    p
      = f.input :translated_text, as: :string, label: 'Translated text', input_html: { class: 'form-control' }
    p
      = f.file_field :picture
    p
      = f.button :submit, data: { disable_with: 'Сохраняется...' }, class: "btn btn-success btn-lg btn-block", id: "btn-login"



my new.js.erb:

$("#modal-window").html("<%= j render 'cards/new' %>");



my create.js.erb:

$("#modal-window").modal("hide");
$(".cards-index").html('<%= j render 'cards/all', cards: @cards %>');
$("#card_title").val('');

Great! Problem solved.
Added gem 'remotipart'
2 Added to the file application.js after //= require jquery_ujs string //= require jquery.remotipart
3 Added to the form string authenticity_token: true

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM