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

  • Home
  • SEARCH
  • 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 7726595
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:15:19+00:00 2026-06-01T05:15:19+00:00

I am having issues with paperclip in my rails application. I am able to

  • 0

I am having issues with paperclip in my rails application. I am able to attach multiple files (PDFs) to my form, but when I try to show more than 1 attachment in the show.html.erb file I get errors.

The code that works in the edit and new views:

            <%= f.fields_for :assets do |asset| %>

               <% if asset.object.new_record? %>
                     <%= asset.file_field :document %>
               <% end %>

           <% end %>

    </div>

    <div class="existingPaperclipFiles">

         <% f.fields_for :assets do |asset| %>

              <% unless asset.object.new_record? %>

                    <div class="thumbnail">
                            <%= link_to( image_tag(asset.object.document.url(:thumb)), asset.object.document.url(:original) ) %>
                            <%= asset.check_box :_destroy %>
                    </div>

              <% end %>        

         <% end %>
    </div>

I have created a separate assets model to keep all the attachments related to my equipment model. When I create a “link_to asset.object.document.url” in the show view I get NoMethod errors. I want to attach both .doc, PDF, and image files to my application if there is a better way than paperclip please help!

The assets model:

class Asset < ActiveRecord::Base
  belongs_to :equipment

  has_attached_file :document, :styles => {:thumb => '150x150#', :medium => '300x300#', :large => '600x600#' }

end

The equipment model:

class Equipment < ActiveRecord::Base
  validates :equipment_id, presence: true
  validates :location, presence: true

  has_many :assets, :dependent => :destroy
  accepts_nested_attributes_for :assets, :allow_destroy => true

end

My equipment_controller:

class EquipmentController < ApplicationController

  def index
    @equipment = Equipment.paginate(page: params[:page])
  end

  def show
    @equipment = Equipment.find(params[:id])


    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @equipment }
    end
  end

  def new
    @equipment = Equipment.new
    5.times {@equipment.assets.build}
  end

  def create
    @equipment = Equipment.new(params[:equipment])

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

  def edit
    @equipment = Equipment.find(params[:id])
    5.times {@equipment.assets.build}
  end

  def update
    @equipment = Equipment.find(params[:id])

    respond_to do |format|
      if @equipment.update_attributes(params[:equipment])
        format.html { redirect_to @equipment, notice: 'Equipment was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit" }
        format.json { render json: @equipment.errors, status: :unprocessable_entity }
      end
    end
  end

  def destroy
    @equipment = Equipment.find(params[:id])
    @equipment.destroy

    respond_to do |format|
      format.html { redirect_to equipment_url }
      format.json { head :no_content }
    end
  end

  private

    def correct_user
      @Equipment = Equipment.find(params[:id])
      redirect_to(root_path) unless current_user?(@Equipment)
    end

    def admin_user
      redirect_to(root_path) unless current_user.admin?
    end
end

Any help is greatly appreciated.

  • 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-01T05:15:20+00:00Added an answer on June 1, 2026 at 5:15 am

    I actually was able to figure this out by doing the following:

      <% for asset in @equipment.assets %>
        <p>
        <%= link_to asset.document_file_name,
                              asset.document.url(:original) %>
        </p>
      <% end %>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am having issues with asset_path in production. Rails 3.1.1 #config/environments/development.rb Scc::Application.configure do #
I am currently having issues uploading files to amazon S3 while using paperclip. It
I'm having issues customizing a radio button for a specific form using hook_theme. Below
I'm having issues parsing some XML using DefaultHandler2. My XML takes the following form:
Im having issues deploying a silverlight 3 application for the first time. The issue
I am having issues compiling the decNumber http://speleotrove.com/decimal/ , source is here http://download.icu-project.org/files/decNumber/decNumber-icu-368.zip (includes
I'm following the following blog list below and I'm having issues getting paperclip 2.3.6
I am trying to attach files in my RoR app. I am using Rails
Having issues with a rails 2.2.2 app running on a VPS (Ubuntu 8.10): looking
Having some odd issues with paperclip, s3 and imagemagick. The normal sized image will

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.