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 7821477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T07:39:51+00:00 2026-06-02T07:39:51+00:00

Well I’m stuck again. And this time, maybe it’s because I’m using a tool

  • 0

Well I’m stuck again. And this time, maybe it’s because I’m using a tool in a way for which it was not designed.

I am using Paperclip for image attachments, and I’m saving these images as instances of a model called, you guessed it, Image. Images belong to users. Users have many images.

However, I want to specify ONE of the user’s images as their default image. So, my brain tells me that I need to add a field to the User table to hold the ID of the image I want to be the default.

Images use has_attached_file. I don’t want users to have their own attached file, I just want the user model to be able to reference a specific instance of an image that has the url helper methods available to it.

The problem comes in when I’m trying to get the URL for this image using the ID. Either what I’m trying to do is impossible using paperclip, or I don’t have my associations set up correctly.

Basically I want to be able to access that image in a view, using an instance of a user model. So:

<%= image_tag @user.image.url %>

But this doesn’t work. I get why it doesn’t work, but I don’t understand how to make

@user.image

be an instance of a magical paperclip object that has the methods attached to it to retrieve the url.

Basically if I knew how to get a paperclip image’s URL using the images ID i’d be golden. Any clues?

  • 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-02T07:39:52+00:00Added an answer on June 2, 2026 at 7:39 am

    I suppose you can get the paperclip image URL from the image object?

    If so, add this to you users model:

    def image_url
      Image.find( self.image ).url
    end
    

    When you now have the ID of the default picture saved in the user model “image” column and the url of an image in the “url” column in the Image model, you should be able to do this:

    @user.image_url
    

    And this should return the url of your “default” image

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

Sidebar

Related Questions

Well, not random, because its the same every time, but #include<iostream> using namespace std;
Well, I am abit confuse using these \r,\n,\t etc things. Because I read online
Well, this must be a silly one. Here below is a can-not-be-simpler code in
Well friends, I have got this query which works but is very long for
Well I am using the following code to take any old image into a
Well, to begin with, I'm using Visual Studio 2008 on a 32-bits Windows XP
Well, how to create picture link like this up or down votes (on the
Well it's not realy causing any errors. Anyways i'm sending ajax request and getting
Well I'm making an program about payrolls and I'm stuck. In the program, after
Well im here because i have a problem. i have code that was created

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.