首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >到Rails authenticity_token不工作

到Rails authenticity_token不工作
EN

Stack Overflow用户
提问于 2014-09-21 11:55:48
回答 1查看 215关注 0票数 0

我是Rails的初级程序员。

我有一个表单,它添加了一个附加的对象。该文件存储在亚马逊S3的云上。

表单通过javascript使用ujs完成。以添加参数的形式出现:remote: true。但是保存没有发生,并且有一个错误:

Missing template cards/create, application/create with {:locale=>[:en], :formats=>[:html], :handlers=>[:erb, :builder, :raw, :ruby, :jbuilder, :coffee, :slim]}.

帮我做什么?

my form:

代码语言:javascript
复制
  = 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:

代码语言:javascript
复制
$("#modal-window").html("<%= j render 'cards/new' %>");

my create.js.erb:

代码语言:javascript
复制
$("#modal-window").modal("hide");
$(".cards-index").html('<%= j render 'cards/all', cards: @cards %>');
$("#card_title").val('');
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-09-21 13:53:23

太棒了!问题解决了。

添加gem 'remotipart'

2添加到文件application.js后的//= require jquery_ujs字符串//= require jquery.remotipart之后。

3添加到表单字符串authenticity_token: true中。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/25958925

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档