Note that there are some explanatory texts on larger screens.

plurals
  1. POAsset model missing required attr_accessor with Paperclip
    text
    copied!<p>I am trying to upload more than 1 file asset to a movie. I keep receiving an error <code>Asset model missing required attr_accessor for 'asset_file_name'</code> and I am not sure why, here is my code:</p> <p>asset.rb model</p> <pre><code>class Asset &lt; ActiveRecord::Base belongs_to :movie has_attached_file :asset end </code></pre> <p>movie.rb model</p> <pre><code>class Movie &lt; ActiveRecord::Base belongs_to :user has_many :assets accepts_nested_attributes_for :assets validates :title, presence: true default_scope order: 'movies.created_at DESC' end </code></pre> <p>I have also ran <code>rails g paperclip movie asset</code> which generated the following migration file</p> <pre><code>class AddAttachmentAssetToMovie &lt; ActiveRecord::Migration def self.up add_column :movies, :asset_file_name, :string add_column :movies, :asset_content_type, :string add_column :movies, :asset_file_size, :integer add_column :movies, :asset_updated_at, :datetime end def self.down remove_column :movies, :asset_file_name remove_column :movies, :asset_content_type remove_column :movies, :asset_file_size remove_column :movies, :asset_updated_at end end </code></pre> <p>And here is my "create assets" migration that came from when I generated the asset model:</p> <pre><code>class CreateAssets &lt; ActiveRecord::Migration def change create_table :assets do |t| t.string :asset_file_name t.integer :asset_file_size t.string :asset_content_type t.datetime :asset_updated_at t.text :asset_description t.integer :movie_id t.timestamps end end </code></pre> <p>Can any suggest why i would be receiving the error <code>Asset model missing required attr_accessor for 'asset_file_name'</code>?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload