I'm trying to create some kind of activity feed, and I'm having trouble getting the values I need to.
I have a controller with this action
def show
@user = User.find(params[:id])
@ideas = Idea.find(@user)
@lists = List.find(@user)
@li_array = (@lists + @ideas).sort{|a,b| -(a.created_at <=> b.created_at)}
end
I'm new to rails, and I'm trying to put together an array of values from the users of both ideas and lists. But I figured out that I can't do what I'm doing now because it will only pass the current user's id to match an id for Idea/List, but what I need to do is find the user's id column and search through based on @user.
I need to get all values from the users, what is the best method?
models
user.rb
has_many :lists
has_many :ideas, :through => :lists
list.rb
has_many :ideas
belongs_to :user
idea.rb
belongs_to :list
belongs_to :user
Thanks