私はroutes.dbに行があります:
resources :specificationItems
私のspecification_item.rbモデル:
class SpecificationItem < ActiveRecord::Base
attr_accessible :amount, :item_id, :price, :specification_id, :total
belongs_to :specification
belongs_to :item
end
Specification_items.rbコントローラー:
class SpecificationItemsController < ApplicationController
def new
@specificationItem = SpecificationItem.new(:specification_id => params[:specification_id])
end
def create
@specificationItem = SpecificationItem.new(params[:specificationitem])
if @specificationItem.save
respond_to do |format|
format.html {
flash[:success] = "Запись добавлена успешно"
redirect_to @specificationItem
}
format.js
end
else
render 'new'
end
end
def show
@specificationitems = SpecificationItem.where("specification_id = ?", @specification.id.to_s)
end
def index
@specificationitems = SpecificationItem.all
end
end
仕様/ショーのこの行で、私は次の新しいアクションを呼び出しspecification_item
ます:
<%= link_to "Add item to spec", new_specificationItem_path(:specification_id =>@specification.id), id: "new_item", remote: true %>
これはnew.js.erbのjsアクションです
$('#new_item').hide().after('<%= j render("form") %>')
部分的な_form.html.erb:
<%= form_for @specificationItem, remote: true do |f| %>
<div class="row">
<div class="span6 offset3">
<%= f.label :item_id, "Товар" %>
<%= f.text_field :item_id %>
<%= f.hidden_field :specification_id %>
</div>
</div>
<%= f.submit "Сохранить", class: "btn btn-large btn-primary" %>
<% end %>
エラーが発生します:
ActionView::Template::Error (undefined method `specification_items_path' for #<#<Class:0xb5b708e4>:0xb5b6e5e4>):
1: <%= form_for @specificationItem, remote: true do |f| %>
2: <div class="row">
3: <div class="span6 offset3">
4: <%= f.label :item_id, "Товар" %>
app/views/specification_items/_form.html.erb:1:in `_app_views_specification_items__form_html_erb___537109236__624411928'
app/views/specification_items/new.js.erb:1:in `_app_views_specification_items_new_js_erb___211974400__624460778'
エラーは命名規則に属していると思われますが、認識できません。私の初心者の質問と間違った英語でごめんなさい
ありがとうございました!