0

私はいくつかのスレッドを読みましたが、これまでのところ何もありません。あるフォームを別のフォームにネストしようとしています。保護された属性を一括割り当てできないというエラーが表示されます。\

app/controllers/projects_controller.rb:46:in new' app/controllers/projects_controller.rb:46:increate'

Projects_controller.rb

 def create
  @project = Project.new(params[:project])


respond_to do |format|
  if @project.save
    format.html { redirect_to @project, notice: 'Project was successfully created.' }
    format.json { render json: @project, status: :created, location: @project }
  else
    format.html { render action: "new" }
    format.json { render json: @project.errors, status: :unprocessable_entity }
  end
 end
end

project.rb

  WF::Application.routes.draw do
    resources :line_items


    resources :projects do
      resources :line_items
    end

   devise_for :users
   get 'about' => 'pages#about'
   get 'Production' => 'projects#index'
   root :to => 'pages#home'
end

ここにエラーがあります...
ActiveModel::MassAssignmentSecurity::ProjectsController#create のエラー

保護された属性を一括割り当てできません: line_item

ここに私のプロジェクトモデルがあります

class Project < ActiveRecord::Base
    attr_accessible :quantity
    # may be unnessary
    attr_accessible :line_items_attributes


    belongs_to :user
    has_many :line_items
    accepts_nested_attributes_for :line_items, :allow_destroy => true
end
4

2 に答える 2