我想通过玩玩东西来学习Ruby on Rails,我正在尝试与Grit一起玩。不过,我有点困惑,来自PHP背景,我从中得到回购的东西。我的代码Ruby On Rails基本变量
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
我想转储出对象的信息,但我似乎无法访问回购变量。我的IDE和Ruby一直在说undefined local variable or method repo'
,我不知道为什么它不能访问repo变量,它是在类的顶部声明的?