在搜索了一段时间并将其缩小到一个特定问题之后,我决定最终注册并向各位好心人寻求帮助。开始:
我创建了一个表格:
= form_for @note, :remote => true do |f|
在控制器内使用 .build(或 .create):
class NotesController < ApplicationController
before_filter :authenticate_user!
respond_to :html, :js
def create
@note = current_user.notes.build(params[:note])
if @note.save
respond_with @note, :location => root_url
end
end
它循环两次创建块。
如果我使用Note.new
或删除:remote => true
,那么一切正常,但两者的结合会破坏一切。笔记创建在控制台中工作正常,它不会在任何地方抛出任何错误,所以我被卡住了。
有人有什么建议吗?