Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8888009
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:56:40+00:00 2026-06-14T21:56:40+00:00

I followed the tutorial screencast over here: http://www.emersonlackey.com/article/rails-paperclip-multiple-file-uploads . I want my model have

  • 0

I followed the tutorial screencast over here: http://www.emersonlackey.com/article/rails-paperclip-multiple-file-uploads. I want my model have multiple pictures upload show up.

I have examined carefully every steps, the most common issue is forget to add assets_attributes to attr_accessible, I have done that. Another issues might bbe forgot to add ID to asset model, i done that too. However, I still have trouble understanding why it happen.

Can't mass-assign protected attributes: asset in app/controllers/posts_controller.rb:24:in `update'

I have already add list of all attributes for a Post to post model. Like:

class Post < ActiveRecord::Base
  attr_accessible :name, :content, :assets_attributes 
  validates :user_id, presence: true
  belongs_to :user
  has_many :assets
  accepts_nested_attributes_for :assets, :allow_destroy => true
  default_scope order: 'posts.created_at DESC'
 end

Here is the post_controller.rb file:

 def edit
    @post = Post.find(params[:id])
    5.times { @post.assets.build }
 end
 def update
    @post = Post.find(params[:id])
    if @post.update_attributes(params[:post])      
          redirect_to @post, :notice => "Post has been updated."
 end
def create
    post = current_user.posts.build(params[:post])
    if post.save
        flash[:success] = "post created success!"
        redirect_to @post
    else
        @feed_items = []
        flash[:failure] = "post created fail!"
        redirect_to root_path
    end
 end
 def new
    @post = current_user.posts.new #if signed_in?
    5.times { @post.assets.build }
 end

Here is the template file:

        <%= simple_form_for(@post, :html => {:multipart => true})  do |f| %>
           <%= f.label :name %>
           <%= f.text_field :name %>
           <%= f.label :content %>
           <%= f.text_field :content %>
           <%= f.simple_fields_for :assets, :html => { :multipart => true } do |asset_fields| %>
               <% if asset_fields.object.new_record? %>
                   <P><%= asset_fields.file_field :asset %> </P>
               <% end %>
           <% end %>
            <%= f.simple_fields_for :assets, :html => { :multipart => true } do |asset_fields| %>
               <% unless asset_fields.object.new_record? %>
                  <P><%= link_to image_tag(asset_fields.object.asset.url(:thumb)), asset_fields.objects.asset.url(:original) %>
                     <%= asset_fields.check_box :_destroy %></P>
               <% end %>
           <% end %>

Below is asset.rb:

    class Asset < ActiveRecord::Base
      belongs_to :post
      has_attached_file :asset,
                :style => { :large => "640x480", :medium => "300x300", :thumb => "100x100"} ,
                :path => ":rails_root/public/system/posts/images/:id/:style/:filename",
                :url => "/system/posts/images/:id/:style/:filename"
    end

Can someone give me some hint ? Thanks a lot!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T21:56:41+00:00Added an answer on June 14, 2026 at 9:56 pm

    Your Asset model needs to have attr_accessible on it too – specifically for the asset field.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I followed this tutorial http://www.vogella.com/articles/AndroidCloudToDeviceMessaging/article.html I wrote the manifest File giving all the permissions
I am using paperclip and rails. I followed this tutorial: Multiple File Uploads with
I followed this tutorial here: http://www.dannyherran.com/2011/02/facebook-php-sdk-and-codeigniter-for-basic-user-authentication/ It works great but when I enable CSRF
I followed the tutorial at http://www.magentocommerce.com/wiki/5_-_modules_and_development/0_-_module_development_in_magento/installing_custom_attributes_with_your_module step by step to make my module install
I followed the tutorial on http://www.david-amador.com/2009/10/xna-camera-2d-with-zoom-and-rotation/ to achieve a camera that follows my player
I followed the tutorial about how to create a scrollView Page Control: http://www.iosdevnotes.com/2011/03/uiscrollview-paging/ This
I followed this tutorial http://www.ibm.com/developerworks/java/tutorials/j-jni/section2.html (C implementation) for implementing a simple example of JNI
I followed a tutorial on how to add multiple paperclip uploads for a record
I followed this tutorial http://stevejenkins.com/blog/2011/08/how-to-install-apc-alternative-php-cache-on-centos-5-6/ to install apc on my centos vps hosting but
I followed this tutorial and the source code : http://blog.objectgraph.com/index.php/2010/04/20/encrypting-decrypting-base64-encode-decode-in-iphone-objective-c/ And then, I downloaded

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.