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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T04:03:17+00:00 2026-06-15T04:03:17+00:00

I have a rails app with articles and author model. If I have an

  • 0

I have a rails app with articles and author model. If I have an author and a post and want to indicate that the author should be the owner of the article, or that the article belongs to the author, what ist the best practice to do so? In particular:

Does it make a difference if I set

my_article.author_id = author_one.id

or If I do

author_one << my_article

The associations that are used are

  • Author has_many articles
  • Articles belongs_to Author

And, by the way, what would be the best way to look it up if similar questions appear?

  • 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-15T04:03:18+00:00Added an answer on June 15, 2026 at 4:03 am

    There is not difference between the 3 following:

    my_article.author_id = author_one.id
    my_article.save
    # same as
    my_article.author = author_one
    my_article.save
    # same as
    author_one.articles << my_article
    

    To set the owner of a particular post, the most common and readable way would be:

    post.author = author
    post.save
    

    OR shorter version:

    post.update_attributes(author_id: author.id) # call an implicit save
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a really simple Rails app. Basically an article with comments. I want
In my Rails app, I have a model Page which represents one HTML article
I have a rails 2.1 app with order which belongs to group. I want
I have a Rails app with the usual application_controller, and a controller (and model)
I have a Rails app that is served by Apache and Passenger, using only
I have a rails app I want to run on heroku to test. I
I have a Rails app with impressionist and friendly id, I want to show
I have a Rails app that includes pg_search and queue_classic gems. Both of these
I have a Rails 3 app that needs to generate an image and send
I have a Rails app running Rails 3.2.6 and Devise 2.1.2 and I want

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.