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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T00:44:10+00:00 2026-05-26T00:44:10+00:00

I’m modeling my User model and adding profile attributes. I’m looking to add a

  • 0

I’m modeling my User model and adding profile attributes.

I’m looking to add a set of social URLs for the user, starting with about 3 or 4 options and possibly growing to more than 15. It would be very easy for me to just create a separate attribute on the User model for every URL, and then run through them all separately for the profile page. Although this seems like it might be redundant, would this be inappropriate or should I go ahead since the attributes just store a simple string?

If I shouldn’t load them all onto the User model:

What would be the best way to go about doing this with a separate model? Any how would I be able to grab all the social urls a user has created in an @social_urls array?

I’m also looking to associate a specific thumbnail image with each website URL to be displayed with the @social_urls.each do block. I’m confused on how I would call dynamically to the correct image.

Thanks so much for any help or insight.

Edit: would this work to attach a html class with the social site name? and then create a thumbnail using css?

# In erb or (better) a helper
<% User::SOCIAL_SYSTEMS.each do |social_system| 
   url = @user.send(social_system)
   if url %>
     <p><a href="<%= url %>" class="<%=User::SOCIAL_SYSTEM_NAMES[social_system]%>"><%=
           User::SOCIAL_SYSTEM_NAMES[social_system] %></a></p>
<% end
end %>
  • 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-26T00:44:11+00:00Added an answer on May 26, 2026 at 12:44 am

    Creating additional attributes on the User model for independent facts (the social urls) is fine.

    Or you could have another two models just for social urls with structure

    SocialUrl
      id
      user_id 
      social_system_id
      value
    
    SocialSystem
      id
      name   # name of the social system ("Google +", "Facebook", etc)
    

    But no need for the additional complexity of the two extra tables unless you really see a value.

    Re:

    running through them all (the social url attributes)

    You can (and should) create helper methods for your User model. Eg, you can have the names of the social attributes as a CONST array and then use #send to retrieve all their values.

    Added The tradeoffs between the two styles (either using the User model or creating two additional models)–

    • How often will you be adding new social systems?

    In terms of space, db storage is so cheap that it makes no difference. — Ie the User model style is sparser storage of the data.

    • Extra two models means two more controllers, two more sets of views, testing, security configuring so that only admin can add a new social system, etc.

    I think I would focus on the main part of my app and just use the User model. Simpler and sweeter.

    Added Re comments:

    For the thumbnail, paperclip or similar is the way to go. — It does create an additional model and table, but the plugin handles all the details.

    For showing the urls, you’d use a helper or two. Eg

    User model
      facebook_url string
      google_plus_url
    
    # Constants defined in User model
    SOCIAL_SYSTEMS = ['facebook_url', 'google_plus_url']
    SOCIAL_SYSTEM_NAMES = {'facebook_url' => 'Facebook',
                           'google_plus_url' => 'Google +'}
    
    # In erb or (better) a helper
    <% User::SOCIAL_SYSTEMS.each do |social_system| 
       url = @user.send(social_system)
       if url %>
         <p><a href="<%= url %>"><%=
               User::SOCIAL_SYSTEM_NAMES[social_system] %></a></p>
    <% end
    end %>
    

    Added ps
    If you need to store more than one fact per social system (eg url for the profile from the social system plus the person’s latest score from the social system), then I would go for the additional tables. But if you only need a single fact (eg the person’s profile url), then adding to the user model is fine. (imho)

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

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a jquery bug and I've been looking for hours now, I can't
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I'm parsing an XML file, the creators of it stuck in a bunch social
I am using Paperclip to handle profile photo uploads in my app. They upload
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and

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.