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

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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T08:38:58+00:00 2026-06-01T08:38:58+00:00

I am trying to learn Ruby on Rails by playing around with stuff and

  • 0

I am trying to learn Ruby on Rails by playing around with stuff and I’m attempting to play around with Grit. However I am a bit confused coming from a PHP background where I get the repo stuff from. My code

class RepoController < ApplicationController
  require "grit"
  repo = Grit::Repo.new("blahblahblah")

  def index()
    puts YAML::dump(repo)
  end

  def show()
    repo.commits('master', 10)
    puts repo.inspect
  end
end

I am trying to dump out information on the objects, but I cannot seem to access the repo variable. My IDE and Ruby keep saying undefined local variable or method repo' and I don’t know why it cannot access the repo variable, it’s declared at the top of the class?

  • 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-06-01T08:39:00+00:00Added an answer on June 1, 2026 at 8:39 am

    You’ve got scope problems. Try:

    require 'grit'
    
    class RepoController < ApplicationController
      def repo
        @repo ||= Grit::Repo.new("blahblahblah")
      end
    
      def index()
        puts YAML::dump(repo)
      end
    
      def show()
        repo.commits('master', 10)
        puts repo.inspect
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to learn rails from http://ruby.railstutorial.org/ Exercise 3 explains to install rspec,
I am trying to learn Ruby on Rails, I have followed the instructions from
Coming from a long history of C-style syntax and now trying to learn Ruby
I am trying to learn Ruby on Rails using this Rails Tutorial. Earlier, I
I am trying to learn Ruby on Rails and trying to write some of
I'm trying to learn Ruby as well as Ruby on Rails right now. I'm
I am trying to learn Ruby, and want to implement the Python algorithms from
I am currently trying to learn Ruby On Rails as I am a long-time
I'm trying to learn C from a Ruby/PHP/Java background, and I've found that you
I'm trying to learn web-dev and decided to learn ruby on rails. I'm doing

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.