How to display a list of multiple modelHow to get a random number in RubyWhat's the best manner of implementing a social activity stream?How to write a switch statement in RubyHow to make --no-ri --no-rdoc the default for gem install?How can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Compile data from different models into one listDisplaying associated data in rails (user_id, email, etc)How to display checkbox values in rails viewHow to give an order to some values in a multiple Class array in Rails?
How should I tell my manager I'm not paying for an optional after work event I'm not going to?
What are the differences between credential stuffing and password spraying?
Emotional immaturity of comic-book version of superhero Shazam
How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?
Building a list of products from the elements in another list
Do I add my skill check modifier to the roll of 15 granted by Glibness?
What was Bran's plan to kill the Night King?
What if the end-user didn't have the required library?
A factorization game
Why wasn't the Night King naked in S08E03?
ZSPL language, anyone heard of it?
What exactly are the `size issues' preventing formation of presheaves being a left adjoint to some forgetful functor?
How long would it take for people to notice a mass disappearance?
Why did Thanos need his ship to help him in the battle scene?
What is a smasher?
What to use instead of cling film to wrap pastry
How can I roleplay a follower-type character when I as a player have a leader-type personality?
Should I decline this job offer that requires relocating to an area with high cost of living?
Nominativ or Akkusativ
Decoupling cap routing on a 4 layer PCB
How did the Venus Express detect lightning?
Where are the "shires" in the UK?
Will 700 more planes a day fly because of the Heathrow expansion?
Are pressure-treated posts that have been submerged for a few days ruined?
How to display a list of multiple model
How to get a random number in RubyWhat's the best manner of implementing a social activity stream?How to write a switch statement in RubyHow to make --no-ri --no-rdoc the default for gem install?How can I rename a database column in a Ruby on Rails migration?How do I get the current absolute URL in Ruby on Rails?Compile data from different models into one listDisplaying associated data in rails (user_id, email, etc)How to display checkbox values in rails viewHow to give an order to some values in a multiple Class array in Rails?
.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;
I'm working on a social networking media like Facebook.
Users can create daily posts and events.
In timeline, I want to display a combined list of @post
and @event
. Can I build that on Rails?
How about this below in controller:
@feed = Post.all + Event.all
And I should divide each thumbnail view also.
So multiple item combined.
ruby-on-rails ruby
add a comment |
I'm working on a social networking media like Facebook.
Users can create daily posts and events.
In timeline, I want to display a combined list of @post
and @event
. Can I build that on Rails?
How about this below in controller:
@feed = Post.all + Event.all
And I should divide each thumbnail view also.
So multiple item combined.
ruby-on-rails ruby
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?
– Vbp
Mar 22 at 23:13
@Vbp Sure, I want to build that.@event
and@post
are listed with sort by created time. In a feed, event -> post -> post -> event.
– k10a
Mar 22 at 23:17
I am not sure what you mean byIn a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?
– Vbp
Mar 22 at 23:56
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13
add a comment |
I'm working on a social networking media like Facebook.
Users can create daily posts and events.
In timeline, I want to display a combined list of @post
and @event
. Can I build that on Rails?
How about this below in controller:
@feed = Post.all + Event.all
And I should divide each thumbnail view also.
So multiple item combined.
ruby-on-rails ruby
I'm working on a social networking media like Facebook.
Users can create daily posts and events.
In timeline, I want to display a combined list of @post
and @event
. Can I build that on Rails?
How about this below in controller:
@feed = Post.all + Event.all
And I should divide each thumbnail view also.
So multiple item combined.
ruby-on-rails ruby
ruby-on-rails ruby
edited Mar 23 at 0:12
k10a
asked Mar 22 at 23:06
k10ak10a
417
417
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?
– Vbp
Mar 22 at 23:13
@Vbp Sure, I want to build that.@event
and@post
are listed with sort by created time. In a feed, event -> post -> post -> event.
– k10a
Mar 22 at 23:17
I am not sure what you mean byIn a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?
– Vbp
Mar 22 at 23:56
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13
add a comment |
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?
– Vbp
Mar 22 at 23:13
@Vbp Sure, I want to build that.@event
and@post
are listed with sort by created time. In a feed, event -> post -> post -> event.
– k10a
Mar 22 at 23:17
I am not sure what you mean byIn a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?
– Vbp
Mar 22 at 23:56
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?– Vbp
Mar 22 at 23:13
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?– Vbp
Mar 22 at 23:13
@Vbp Sure, I want to build that.
@event
and @post
are listed with sort by created time. In a feed, event -> post -> post -> event.– k10a
Mar 22 at 23:17
@Vbp Sure, I want to build that.
@event
and @post
are listed with sort by created time. In a feed, event -> post -> post -> event.– k10a
Mar 22 at 23:17
I am not sure what you mean by
In a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?– Vbp
Mar 22 at 23:56
I am not sure what you mean by
In a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?– Vbp
Mar 22 at 23:56
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13
add a comment |
2 Answers
2
active
oldest
votes
Adding every single Post and Event to an array on memory es really dangerous, don't do that!
I can think of 2 solutions for your problem.
1- The easiest
Add an extra model with a polymorphic association to a Post or an Event and the created_at every time you create one of them. Then you can sort and paginate that extra model at database level. This way you won't have memory problems.
You could have some helper method to preload the post and events of that result set to prevent an N+1 queries problem since you can't use includes/references on polymorphic associations.
Pros: easy to implement
Cons: adds an extra model, you need to implement the preload of information to prevent N+1 queries, if you need to add some where statement you'll have to copy the data or join the table with the others.
2- The hardest
Use a UNION query with both tables and return the necesary fields just to display them.
union_qry = "(SELECT 'Post', id, created_at, '' as title, '' as place FROM posts) UNION (SELECT 'Event', id, created_at, title, place FROM events)"
arr = ActiveRecord::Base.connection.execute("#search_qry ORDER BY created_at DESC LIMIT #per OFFSET #offset") #note the per and offset if you need pagination
That query will return a MySQL::Result that you can iterate and for each record you'll have an array like:
['Post', post_id, post_created_at, '', '']
or
['Event', event_id, event_created_at, event_title, event_place]
With those arrays you can build your list of Post+Event, if you need more data just add that to the UNION statement.
Pros: no need for an extra element, no need to repeat info, you can use where on other fields
Cons: it's far from ActiveRecord, no nice queries, no nice ActiveRecor object
Personally I prefer option 2, it's more flexible, but option 1 is easier.
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
add a comment |
Here's a very simple implementation of what you're asking for:
@feed = [*Post.all, *Event.all].sort_by(&:created_at)
Then in your view:
@feed.each do |thing|
# thing can be a Post or an Event
end
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
1
Be careful with this, if you have too many posts and eventsPost.all
andEvent.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.
– arieljuod
Mar 23 at 2:19
|
show 2 more comments
Your Answer
StackExchange.ifUsing("editor", function ()
StackExchange.using("externalEditor", function ()
StackExchange.using("snippets", function ()
StackExchange.snippets.init();
);
);
, "code-snippets");
StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "1"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);
else
createEditor();
);
function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);
);
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308877%2fhow-to-display-a-list-of-multiple-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
Adding every single Post and Event to an array on memory es really dangerous, don't do that!
I can think of 2 solutions for your problem.
1- The easiest
Add an extra model with a polymorphic association to a Post or an Event and the created_at every time you create one of them. Then you can sort and paginate that extra model at database level. This way you won't have memory problems.
You could have some helper method to preload the post and events of that result set to prevent an N+1 queries problem since you can't use includes/references on polymorphic associations.
Pros: easy to implement
Cons: adds an extra model, you need to implement the preload of information to prevent N+1 queries, if you need to add some where statement you'll have to copy the data or join the table with the others.
2- The hardest
Use a UNION query with both tables and return the necesary fields just to display them.
union_qry = "(SELECT 'Post', id, created_at, '' as title, '' as place FROM posts) UNION (SELECT 'Event', id, created_at, title, place FROM events)"
arr = ActiveRecord::Base.connection.execute("#search_qry ORDER BY created_at DESC LIMIT #per OFFSET #offset") #note the per and offset if you need pagination
That query will return a MySQL::Result that you can iterate and for each record you'll have an array like:
['Post', post_id, post_created_at, '', '']
or
['Event', event_id, event_created_at, event_title, event_place]
With those arrays you can build your list of Post+Event, if you need more data just add that to the UNION statement.
Pros: no need for an extra element, no need to repeat info, you can use where on other fields
Cons: it's far from ActiveRecord, no nice queries, no nice ActiveRecor object
Personally I prefer option 2, it's more flexible, but option 1 is easier.
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
add a comment |
Adding every single Post and Event to an array on memory es really dangerous, don't do that!
I can think of 2 solutions for your problem.
1- The easiest
Add an extra model with a polymorphic association to a Post or an Event and the created_at every time you create one of them. Then you can sort and paginate that extra model at database level. This way you won't have memory problems.
You could have some helper method to preload the post and events of that result set to prevent an N+1 queries problem since you can't use includes/references on polymorphic associations.
Pros: easy to implement
Cons: adds an extra model, you need to implement the preload of information to prevent N+1 queries, if you need to add some where statement you'll have to copy the data or join the table with the others.
2- The hardest
Use a UNION query with both tables and return the necesary fields just to display them.
union_qry = "(SELECT 'Post', id, created_at, '' as title, '' as place FROM posts) UNION (SELECT 'Event', id, created_at, title, place FROM events)"
arr = ActiveRecord::Base.connection.execute("#search_qry ORDER BY created_at DESC LIMIT #per OFFSET #offset") #note the per and offset if you need pagination
That query will return a MySQL::Result that you can iterate and for each record you'll have an array like:
['Post', post_id, post_created_at, '', '']
or
['Event', event_id, event_created_at, event_title, event_place]
With those arrays you can build your list of Post+Event, if you need more data just add that to the UNION statement.
Pros: no need for an extra element, no need to repeat info, you can use where on other fields
Cons: it's far from ActiveRecord, no nice queries, no nice ActiveRecor object
Personally I prefer option 2, it's more flexible, but option 1 is easier.
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
add a comment |
Adding every single Post and Event to an array on memory es really dangerous, don't do that!
I can think of 2 solutions for your problem.
1- The easiest
Add an extra model with a polymorphic association to a Post or an Event and the created_at every time you create one of them. Then you can sort and paginate that extra model at database level. This way you won't have memory problems.
You could have some helper method to preload the post and events of that result set to prevent an N+1 queries problem since you can't use includes/references on polymorphic associations.
Pros: easy to implement
Cons: adds an extra model, you need to implement the preload of information to prevent N+1 queries, if you need to add some where statement you'll have to copy the data or join the table with the others.
2- The hardest
Use a UNION query with both tables and return the necesary fields just to display them.
union_qry = "(SELECT 'Post', id, created_at, '' as title, '' as place FROM posts) UNION (SELECT 'Event', id, created_at, title, place FROM events)"
arr = ActiveRecord::Base.connection.execute("#search_qry ORDER BY created_at DESC LIMIT #per OFFSET #offset") #note the per and offset if you need pagination
That query will return a MySQL::Result that you can iterate and for each record you'll have an array like:
['Post', post_id, post_created_at, '', '']
or
['Event', event_id, event_created_at, event_title, event_place]
With those arrays you can build your list of Post+Event, if you need more data just add that to the UNION statement.
Pros: no need for an extra element, no need to repeat info, you can use where on other fields
Cons: it's far from ActiveRecord, no nice queries, no nice ActiveRecor object
Personally I prefer option 2, it's more flexible, but option 1 is easier.
Adding every single Post and Event to an array on memory es really dangerous, don't do that!
I can think of 2 solutions for your problem.
1- The easiest
Add an extra model with a polymorphic association to a Post or an Event and the created_at every time you create one of them. Then you can sort and paginate that extra model at database level. This way you won't have memory problems.
You could have some helper method to preload the post and events of that result set to prevent an N+1 queries problem since you can't use includes/references on polymorphic associations.
Pros: easy to implement
Cons: adds an extra model, you need to implement the preload of information to prevent N+1 queries, if you need to add some where statement you'll have to copy the data or join the table with the others.
2- The hardest
Use a UNION query with both tables and return the necesary fields just to display them.
union_qry = "(SELECT 'Post', id, created_at, '' as title, '' as place FROM posts) UNION (SELECT 'Event', id, created_at, title, place FROM events)"
arr = ActiveRecord::Base.connection.execute("#search_qry ORDER BY created_at DESC LIMIT #per OFFSET #offset") #note the per and offset if you need pagination
That query will return a MySQL::Result that you can iterate and for each record you'll have an array like:
['Post', post_id, post_created_at, '', '']
or
['Event', event_id, event_created_at, event_title, event_place]
With those arrays you can build your list of Post+Event, if you need more data just add that to the UNION statement.
Pros: no need for an extra element, no need to repeat info, you can use where on other fields
Cons: it's far from ActiveRecord, no nice queries, no nice ActiveRecor object
Personally I prefer option 2, it's more flexible, but option 1 is easier.
answered Mar 23 at 2:40
arieljuodarieljuod
8,17111222
8,17111222
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
add a comment |
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
Thanks so much @arieljuod I really appreciate that, I'm still beginner but I have decided to try to build with the hardest one.
– k10a
Mar 23 at 8:50
add a comment |
Here's a very simple implementation of what you're asking for:
@feed = [*Post.all, *Event.all].sort_by(&:created_at)
Then in your view:
@feed.each do |thing|
# thing can be a Post or an Event
end
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
1
Be careful with this, if you have too many posts and eventsPost.all
andEvent.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.
– arieljuod
Mar 23 at 2:19
|
show 2 more comments
Here's a very simple implementation of what you're asking for:
@feed = [*Post.all, *Event.all].sort_by(&:created_at)
Then in your view:
@feed.each do |thing|
# thing can be a Post or an Event
end
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
1
Be careful with this, if you have too many posts and eventsPost.all
andEvent.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.
– arieljuod
Mar 23 at 2:19
|
show 2 more comments
Here's a very simple implementation of what you're asking for:
@feed = [*Post.all, *Event.all].sort_by(&:created_at)
Then in your view:
@feed.each do |thing|
# thing can be a Post or an Event
end
Here's a very simple implementation of what you're asking for:
@feed = [*Post.all, *Event.all].sort_by(&:created_at)
Then in your view:
@feed.each do |thing|
# thing can be a Post or an Event
end
answered Mar 23 at 0:32
NickNick
84499
84499
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
1
Be careful with this, if you have too many posts and eventsPost.all
andEvent.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.
– arieljuod
Mar 23 at 2:19
|
show 2 more comments
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
1
Be careful with this, if you have too many posts and eventsPost.all
andEvent.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.
– arieljuod
Mar 23 at 2:19
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
Thanks Nick! But I want to ask you, how can I divide a partial? Because Post has title and content, but Event has title, content, date and place. So they may be different.
– k10a
Mar 23 at 0:46
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
I'm not sure what you mean, but if you're asking how to display the posts and events in your loop, you could make a partial for each type: _post.html.erb and _event.html.erb. Then, in your loop (in e.g. index.html.erb), render the partial that corresponds to the current object type.
– Nick
Mar 23 at 0:50
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Perfect! Thanks a lot!!!
– k10a
Mar 23 at 0:58
Happy to help out
– Nick
Mar 23 at 0:59
Happy to help out
– Nick
Mar 23 at 0:59
1
1
Be careful with this, if you have too many posts and events
Post.all
and Event.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.– arieljuod
Mar 23 at 2:19
Be careful with this, if you have too many posts and events
Post.all
and Event.all
will load ALL of them on memory to sort them. It's a really dangerous approach, it does not scale.– arieljuod
Mar 23 at 2:19
|
show 2 more comments
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55308877%2fhow-to-display-a-list-of-multiple-model%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
@posts = Post.all
@events = Event.all
then just iterate through the items to build in view as you need?– Vbp
Mar 22 at 23:13
@Vbp Sure, I want to build that.
@event
and@post
are listed with sort by created time. In a feed, event -> post -> post -> event.– k10a
Mar 22 at 23:17
I am not sure what you mean by
In a feed, event -> post -> post -> event.
what are your requirements? Are you just trying to display a list of events and list of posts on view?– Vbp
Mar 22 at 23:56
@Vbp I have added an image in my question. So In the same feed, I want to list both event item and post item sorted by created time.
– k10a
Mar 23 at 0:13