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 6562387
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T13:42:10+00:00 2026-05-25T13:42:10+00:00

I’m building my first rails app and I have my HTML and CSS files

  • 0

I’m building my first rails app and I have my HTML and CSS files set up in /public and models.rb in /models housing my code.

Right now the code is one Def that searches for the 5 most recent tweets mentioning me in the models.rb file.

I want to take those 5 tweets and style them in a certain way. I’ve never accessed data from one file to another so not quite sure how to get those tweets to appear in the index.html file.

Any help much appreciated.

require 'rubygems'
require 'twitter'

def search
  search = Twitter::Search.new
  search.containing("@twitter").result_type("recent").per_page(5).each do |r|
     puts "#{r.from_user}: #{r.text}"
  end
end

search #calls search function

That is the code in models.rb, need to get that to show in index.html

  • 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-25T13:42:11+00:00Added an answer on May 25, 2026 at 1:42 pm

    First of all, you want to organize your files properly. You didn’t mention controllers, but you’ll need one for each type of ‘thing’ you want users to interact with. See: http://guides.rubyonrails.org/action_controller_overview.html

    You want a file structure like this:

    CSS in /public/stylesheets/whatever.css
    HTML in /app/views/tweets/index.html.erb

    Bear in mind I’m not familiar with your specific database structure, but in the tweets controller (stored in /app/controllers/tweets_controller.rb) you’d ideally want to be able to do this:

    def index
        @tweets = @user.tweets.order("tweets.created_at DESC").limit(5)
    end
    

    Then in index.html.erb:

    <% @tweets.each do |tweet| %>
        <div class="tweet">
            <%= @tweet.text %>
        </div>
    <% end %>
    

    This is the most detail I can give you from your question – you should read about the MVC structure in rails and most of all, take the time to get your project started/organized well. It’ll save lots of headache for you in the future!

    Best of luck.

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

Sidebar

Related Questions

We're building an app, our first using Rails 3, and we're having to build
I have this code to decode numeric html entities to the UTF8 equivalent character.
I have thousands of HTML files to process using Groovy/Java and I need to
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
this is what i have right now Drawing an RSS feed into the php,
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I have a bunch of posts stored in text files formatted in yaml/textile (from
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't

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.