画像をアップロードして処理する Rails アプリを開発しています。画像は、他の文字列情報とともに、form_for を介して送信されます。このトピックについて約 16 時間調査してきましたが、解決策はありません。正直なところ、Rails が私のコードを読み取っていないようです。
1 つの Processmodel には多くの Asset があり、Asset は 1 つの画像ファイルを保持するための単なるモデルです。プロセスモデルを作成するとき、資産にアクセスできず、常に一括割り当てできない属性を受け取ります: assets_attributes
Completed 500 Internal Server Error in 13ms
ActiveModel::MassAssignmentSecurity::Error (Can't mass-assign protected attributes: asset):
  app/controllers/process_controller.rb:20:in `new'
  app/controllers/process_controller.rb:20:in `create'
- このフォームは new.html.erb で使用されます
<%= semantic_form_for @processmodel, :url => { :action => 'create' }, :html => {     :multipart => true } do |f| %>
    <%= f.input :batch, :as => :string, :name => "Batch" %>
    <%= f.input :batchset, :as => :string, :name => "Batchset" %>
    <%= f.input :numSlots, :as => :number, :name => "Number of slots" %>    
    <%= f.input :key, :as => :file, :name => "Key" %>   
    <%= f.semantic_fields_for :asset do |asset| %> 
        <%= asset.input :asset, :as => :file, :label => "Image" %>
    <% end %><br />
    <%= f.submit %>
<% end %>
-
class Processmodel < ActiveRecord::Base
  attr_accessible :user_id, :batch, 
                :batchset, :numSlots,
                :key,:assets_attributes
  attr_accessor :key_file_name
  has_many :assets, :dependent => :destroy
  belongs_to :user  
  has_attached_file :key
  #    :url => Rails.root.join('/assets/readimages/:basename.:extension'),
  #    :path => Rails.root.join('/assets/readimages/:basename.:extension'),
  accepts_nested_attributes_for :assets, :allow_destroy => true
  . 
  . 
  .
end
-
require 'RMagick'
class Asset < ActiveRecord::Base
    attr_accessible :results_string, 
        :name, 
        :ambiguous_results, 
        :image 
    belongs_to :batch_element
    belongs_to :processmodel
    has_attached_file :image 
    validates_attachment_presence :image
end
-
class ProcessController < ApplicationController
def create
    @Processmodel = Processmodel.new(params[:processmodel])
    @Processmodel.save    
    all_img = Array.new(@processmodel.assets.all)
    respond_to do |format|
      if @processmodel.beginRead(...)
        redirect_to :action => 'results_main', :controller => 'results' 
      else
        format.html { render action: "new" }
   end
end 
end
-
def new
  @processmodel = Processmodel.new
  #5.times{@processmodel.assets.build}
  respond_to do |format|
    format.html #new.html.erb
end
end
これを修正してアプリを機能させる方法についてのアイデアを求めています。