Ruby on Rails Gemfile错误

时间:2014-03-31 02:59:06

标签: ruby-on-rails ruby ruby-on-rails-3 heroku

我是网络开发和学习自学指南(odin项目)的新手。我刚刚开始安装我编程所需的所有不同工具,但遇到了问题。在Heroku部署的rails上设置ruby时,我收到语法错误。我正在按照指南http://goo.gl/v2LcbU进行操作,当我尝试执行步骤7.2(捆绑安装 - 没有生产)时,我收到语法错误。我运行ruby -c Gemfile,错误显示Gemfile:37: syntax error, unexpected keyword_do, expecting $end

我已经尝试了一些事情,但我很困惑,不知道它试图说的是第37行的错误。如果你看看我链接的指南,它就是替换了一些Gemfile,这就是我的Gemfile看起来导致错误而不允许我bundle install --without production

的Gemfile http://i.imgur.com/IIjvhwM.png 我正在关联它的图像,因为我还不确定如何正确链接文件,抱歉。

source 'https://rubygems.org'

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.4'

# Use sqlite3 as the database for Active Record
group :development, :test do
gem 'sqlite3'
end

group :production do
gem 'pg'
gem 'rails_12factor'
end

# Use SCSS for stylesheets
gem 'sass-rails', '~> 4.0.2'

# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'

# Use CoffeeScript for .js.coffee assets and views
gem 'coffee-rails', '~> 4.0.0'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby

# Use jquery as the JavaScript library
gem 'jquery-rails'

# Turbolinks makes following links in your web application faster. Read more:       https://github.com/rails/turbolinks
gem 'turbolinks'

# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.2'
group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use unicorn as the app server
# gem 'unicorn'

# Use Capistrano for deployment
# gem 'capistrano', group: :development

# Use debugger
# gem 'debugger', group: [:development, :test]

2 个答案:

答案 0 :(得分:0)

这是无效的:

group
:doc do
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', require: false
end

group是一个被调用的方法,:doc是一个参数,而do...end块就是一个块。在Ruby中,第一个方法参数需要紧跟方法名称。你的小组看起来应该更像这样:

group :doc do
  # bundle exec rake doc:rails generates the API under doc/api.
  gem 'sdoc', require: false
end

答案 1 :(得分:0)

您可以通过运行rails standard命令查看其他示例,如下所示:

rails new apptest

它将自动生成许多文件,包括Gemfile,在底部,你会看到如下内容:

group :development, :test do
  gem 'byebug'
  gem 'web-console', '~> 2.0'
  gem 'spring'
  gem 'rspec-rails'
  gem 'capybara'
end
从这里学习,添加自己的宝石,享受rails :)。