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

  • SEARCH
  • Home
  • 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 6986369
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T18:48:00+00:00 2026-05-27T18:48:00+00:00

I have a simple Twitter mockup set up following rails tutorial and I’m trying

  • 0

I have a simple Twitter mockup set up following rails tutorial and I’m trying to add Endless Page following this: http://railscasts.com/episodes/114-endless-page

Ryan used a products page and index. However, I have a newsfeed going and so certain variables will need to be replaced.

I’ve replaced @products with @feed_items but with no luck. It seems so simple to implement so I’m not sure what I’m doing wrong.

Code Comparison:

Here is my pages controller which would be Ryan’s Product controller

class PagesController < ApplicationController

  def home
    @title = "Home"
    if signed_in?
      @micropost = Micropost.new
      @feed_items = current_user.feed.paginate(:page => params[:page])
    end
  end

Ryan’s Code:

def index
  @products = Product.paginate(:page => params[:page], :per_page => 15)
end

My index.js.rjs (Problem may lie here?)

page.insert_html :bottom, :feed_item, :partial => @feed_items
if @feed_items.total_pages > @feed_items.current_page
  page.call 'checkScroll'
else
  page[:loading].hide
end

Ryan’s Code

page.insert_html :bottom, :products, :partial => @products
if @products.total_pages > @products.current_page
   page.call 'checkScroll'
else
   page[:loading].hide
end

Application_helper.rb (identical to Ryan’s)

def javascript(*args)
  content_for(:head) { javascript_include_tag(*args) }
end

_feed.html.erb

<% unless @feed_items.empty? %>
<% javascript :defaults, 'endless_page' %>
  <table class="microposts" summary="User microposts">
    <%= render :partial => 'shared/feed_item', :collection => @feed_items %>
  </table>
<% end %>
<p id="loading">Loading more page results...</p>

Ryan’s index.html.erb

<% title "Products" %>
<% javascript :defaults, 'endless_page' %>

<div id="products">
  <%= render :partial => @products %>
</div>
<p id="loading">Loading more page results...</p>

endless_page.js [identical to Ryan’s] (problem may lie here in reference to the /products.js line. I tried changing to feed.js but with no luck).

var currentPage = 1;

function checkScroll() {
  if (nearBottomOfPage()) {
    currentPage++;
    new Ajax.Request('/products.js?page=' + currentPage, {asynchronous:true, evalScripts:true, method:'get'});
  } else {
    setTimeout("checkScroll()", 250);
  }
}

function nearBottomOfPage() {
  return scrollDistanceFromBottom() < 150;
}

function scrollDistanceFromBottom(argument) {
  return pageHeight() - (window.pageYOffset + self.innerHeight);
}

function pageHeight() {
  return Math.max(document.body.scrollHeight, document.body.offsetHeight);
}

document.observe('dom:loaded', checkScroll);
  • 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-05-27T18:48:01+00:00Added an answer on May 27, 2026 at 6:48 pm

    I’m pretty new to rails and trying to do something similar. but your GET request, for sure needs to go to your controller rather than the one in the tutorial. maybe you need a render for the .js format in your controller as well?

    I think we are going with jquery instead, but I will try this as well today and update you if I find anything.

    —update. i tried this and it worked fine. i think the tutorial had routes set up as resources. Thats probably where you got stuck. Hope it works for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple bit of jQuery to retrieve my latest Tweet $.getJSON(http://twitter.com/statuses/user_timeline/username.json?count=1,
Today I tried to follow the basic Twitter tutorial on : --> http://www.noupe.com/ajax/create-a-simple-twitter-app.html But
I'm practicing PyQt and (Q)threads by making a simple Twitter client. I have two
Using the Twitter API, and just want to have a simple 'reply' button on
I have developed a simple site that fetches tweets from the Twitter public timeline,
I have found this little script in PHP that send a simple request to
Simple question...I've noticed several large sites (Facebook, Twitter, etc) have ditched the idea of
I have a table called trends_points , this table has the following columns: id
I am trying to write a simple script to publish to my Twitter feed.
I have a twitter feed displaying my tweets on a page. I want to

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.