I have a simple example:
The user has many tweets. Tweet belongs to the user.
And I'm trying to wrest the column name that exists in both tables. For example:
@tweets = Tweet.includes(:user).all.pluck(:created_at)
Each table has a created_at column, but the result at the top returns created_at for the tweet. How can I also snatch user created_at?
My workaround is below using connections and selects:
@tweets = Tweet.joins(:user).select("users.created_at AS created_date").all
So how can I do this using pluck?
source
share