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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:51:30+00:00 2026-05-31T22:51:30+00:00

I have an app where users can sign up with Facebook, in which case

  • 0

I have an app where users can sign up with Facebook, in which case I take the Facebook image, or they can sign up using regular authentication, in which case they’re uploading a photo using CarrierWave gem.

Because of some sort of conflict, I had to create a column in the database (:image)to store the url to the Facebook image, and then a different column (:dimage) to store the url for the image if they signed up using the non-facebook sign up.

So when it comes time to display the user, I’m checking to see if there’s an :image, and, if not, then displaying the other :dimage.

However, I don’t want to require them to upload an image, in which case, I want to display an anon image (here represented by the rails.png). However, the Rails.png isn’t showing up (just a broken image path), so I’m assuming there’s some sort of error with my if else syntax because the image_tag("rails.png") is taken straight from the api

 <% if user.image %>
 <%= image_tag user.image %>
 <% elsif user.dimage %>
 <%= image_tag user.dimage_url(:thumb).to_s %>
 <% else %>
 <%= image_tag("rails.png") %>
 <% end %>

The generated html on the rails.png

<img alt="Assets" src="/assets/">
  • 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-05-31T22:51:31+00:00Added an answer on May 31, 2026 at 10:51 pm

    Use the present? method to check if the attribute is not empty:

    <% if user.image.present? %>
      <%= image_tag user.image %>
    <% elsif user.dimage.present? %>
      <%= image_tag user.dimage_url(:thumb).to_s %>
    <% else %>
      <%= image_tag("rails.png") %>
    <% end %>
    

    You’ll save yourself a headache or two because in Ruby the only falsehoods are false and nil. This means that the empty string "" will actually return true.

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

Sidebar

Related Questions

I have an app in which users can follow law firms I have 3
I have a vector drawing app where users can draw lines using multiple quadratic
We have an HTML5 drawing app where users can draw lines using a pencil
Let's says I have a Djano app. Users can sign up, get a activation
I am building an app in which the users can have different roles (like
I have a form in my django app where users can upload files. How
I have a wizard in my app where users can go back and forward
I can't send email to my app users, even though I have the permissions.
I have a Java app that can authenticate to LDAP by logging users into
I have a rails app which is already running with some users, users that

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.