ruby on rails - show records from two different models using pagination -


I have two models .. video and youtube_video .. There is a index page to show both videos in .i. Therefore, I am pointing the page on both the resultet to the add-on .... array of two in the array to show on the index page. For the total pages that I am doing wrong, I know that this is a work, as it works on ActiveRecord Relationships and does not occur on ActiveRecord . I also tried the model. Where ... but does not work ... any work on this will be appreciated :)

My Controller ..

  @ Videos = Video.includes (: user,: reputations, tags, comments) .paginate (: page => params [: page],: per_page => 10). Order ("created_at DESC") @ youtube_videos = YoutubeVideo.includes (: user, tag). Paginated (: page = & gt; parameter [: page],: per_page => 10) .order ("created_at DESC") @ All_videos = @ video + @youtube_videos   

My view file

  looping at ### @all_videos .... and lieutenant; Div class = "page_info text-center" style = "margin-down: 10px" & gt; & Lt ;! - It breaks here - & gt; & Lt;% = page_entries_info @ all_videos% & gt; & Lt; Hour & gt; & Lt ;! - It also breaks down if I remove the above line - & gt; & Lt;% = ajax_will_paginate @ all_videos% & gt; & Lt; / Div & gt;   

If I just use @videos. .it works, but after the merge .. breaks with any other model .. any ideas?

You are paginating each archive, you have to add them first, then the array must be paginated . / P>

  will need 'will_paginate / array' @videos = Video.includes (: user, reputations, tags, comments) .order ("created_at DESC") @ youtube_videos = YoutubeVideo.includes (: User :: tag) .order ("created_at DESC") @all_videos = (@videos + @youtube_videos) .paginate (: page => parameter [: page],: per_page => 10)   

As you are adding two questions together, it seems that you need to sort the array in the Ruby.

Comments

Popular posts from this blog

java - ImportError: No module named py4j.java_gateway -

python - Receiving "KeyError" after decoding json result from url -

.net - Creating a new Queue Manager and Queue in Websphere MQ (using C#) -