Ruby on rails Rails:当AJAX和.js.rjs文件
我正在尝试使用rails执行AJAX例程 代码正常运行,但响应不正常 我得到这个错误 缺少模板Ruby on rails Rails:当AJAX和.js.rjs文件,ruby-on-rails,ruby,runtime-error,Ruby On Rails,Ruby,Runtime Error,我正在尝试使用rails执行AJAX例程 代码正常运行,但响应不正常 我得到这个错误 缺少模板 Missing template line_items/create, application/create with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "D:/ruby/depot/app/views" 我创建了create
Missing template line_items/create, application/create with {:locale=>[:en], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee]}. Searched in: * "D:/ruby/depot/app/views"
我创建了create.js.rjs in line_items目录,就像《敏捷Web开发》一书中所说的那样,但错误依然存在
#file line_items_controller.rb
def create
@cart = current_cart
product = Product.find(params[:product_id])
@line_item = add_product(@cart, product.id)
respond_to do |format|
if @line_item.save
format.html { redirect_to store_url }
format.js
format.json { render json: @line_item, status: :created, location: @line_item }
#...
end
end
end
在我的create.js.rjs中我得到了这个
page.replace_html('cart', render(@cart))
我想Rjs不再是一种有效的格式了。改用js.erb。另外,您所遵循的手册已经过时,因为再也没有人使用原型了。我注意到。。这是现场的特殊故障。。他们仍然推荐我在问题中提到的这本书。。看到了吗