1.我在ruby-2.0.0 rails-4.0上工作
2.我遵循教程http://ruby.railstutorial.org/chapters/static-pages#top
我跑了#34;捆绑安装"命令。
这是"捆绑安装"的输出。命令
user@user-Latitude-E6410:~/rais_project/sample_app$ bundle install
Using rake (10.1.1)
Using i18n (0.6.9)
Using minitest (4.7.5)
Using multi_json (1.8.4)
Using atomic (1.1.14)
Using thread_safe (0.1.3)
Using tzinfo (0.3.38)
Using activesupport (4.0.3)
Using builder (3.1.4)
Using erubis (2.7.0)
Using rack (1.5.2)
Using rack-test (0.6.2)
Using actionpack (4.0.3)
Using mime-types (1.25.1)
Using polyglot (0.3.4)
Using treetop (1.4.15)
Using mail (2.5.4)
Using actionmailer (4.0.3)
Using activemodel (4.0.3)
Using activerecord-deprecated_finders (1.0.3)
Using arel (4.0.2)
Using activerecord (4.0.3)
Using mini_portile (0.5.2)
Using nokogiri (1.6.1)
Using xpath (2.0.0)
Using capybara (2.1.0)
Using ffi (1.9.3)
Using childprocess (0.5.1)
Using coffee-script-source (1.7.0)
Using execjs (2.0.2)
Using coffee-script (2.2.0)
Using thor (0.18.1)
Using railties (4.0.3)
Using coffee-rails (4.0.1)
Using diff-lcs (1.2.5)
Using hike (1.2.3)
Using jbuilder (1.0.2)
Using jquery-rails (3.0.4)
Using json (1.8.1)
Using bundler (1.5.2)
Using tilt (1.4.1)
Using sprockets (2.11.0)
Using sprockets-rails (2.0.1)
Using rails (4.0.3)
Using rdoc (3.12.2)
Using rspec-core (2.13.1)
Using rspec-expectations (2.13.0)
Using rspec-mocks (2.13.1)
Using rspec-rails (2.13.1)
Using rubyzip (0.9.9)
Using sass (3.2.14)
Using sass-rails (4.0.1)
Using sdoc (0.3.20)
Using websocket (1.0.7)
Using selenium-webdriver (2.35.1)
Using sqlite3 (1.3.8)
Using turbolinks (1.1.1)
Using uglifier (2.1.1)
Your bundle is complete!
Gems in the group production were not installed.
Use `bundle show [gemname]` to see where a bundled gem is installed.
5.接下来我运行了这个命令 " $ rails生成控制器StaticPages主页帮助--no-test-framework"。
根据教程
,输出必须如下所示 create app/controllers/static_pages_controller.rb
route get "static_pages/help"
route get "static_pages/home"
invoke erb
create app/views/static_pages
create app/views/static_pages/home.html.erb
create app/views/static_pages/help.html.erb
invoke helper
create app/helpers/static_pages_helper.rb
invoke assets
invoke coffee
create app/assets/javascripts/static_pages.js.coffee
invoke scss
create app/assets/stylesheets/static_pages.css.scss
但是我得到了输出
/home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:7:in `<module:Handlers>': uninitialized constant Erubis (NameError)
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
from /home/user/rais_project/sample_app/config/application.rb:12:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
6.我尝试了教程中的下一个命令&#34; $ rails generate controller static_pages ...&#34;控制器名为&#34; static_pages_controller.rb&#34;必须已经生成。
&#34; $ rails的输出生成控制器static_pages ...&#34;是
/home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:7:in `<module:Handlers>': uninitialized constant Erubis (NameError)
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
from /home/user/rais_project/sample_app/config/application.rb:12:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
user@user-Latitude-E6410:~/rais_project/sample_app$ clear
user@user-Latitude-E6410:~/rais_project/sample_app$ $ rails generate controller static_pages ...
$: command not found
user@user-Latitude-E6410:~/rais_project/sample_app$ rails generate controller static_pages ...
/home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:7:in `<module:Handlers>': uninitialized constant Erubis (NameError)
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@global/gems/bundler-1.5.2/lib/bundler.rb:131:in `require'
from /home/user/rais_project/sample_app/config/application.rb:12:in `<top (required)>'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/ruby-2.0.0-p353@railstutorial_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `<top (required)>'
from bin/rails:4:in `require'
from bin/rails:4:in `<main>'
但是这个控制器没有生成。请你帮忙吗?
Gemfile
source 'https://rubygems.org'
ruby '2.0.0'
#ruby-gemset=railstutorial_rails_4_0
gem 'rails', '4.0.3'
group :development, :test do
gem 'sqlite3', '1.3.8'
gem 'rspec-rails', '2.13.1'
end
group :test do
gem 'selenium-webdriver', '2.35.1'
gem 'capybara', '2.1.0'
end
gem 'sass-rails', '4.0.1'
gem 'uglifier', '2.1.1'
gem 'coffee-rails', '4.0.1'
gem 'jquery-rails', '3.0.4'
gem 'turbolinks', '1.1.1'
gem 'jbuilder', '1.0.2'
group :doc do
gem 'sdoc', '0.3.20', require: false
end
group :production do
gem 'pg', '0.15.1'
gem 'rails_12factor', '0.0.2'
end
答案 0 :(得分:0)
好的,我没有评论的声誉,但在我看来,就像你在这里输入$:
user@user-Latitude-E6410:~/rais_project/sample_app$ $ rails generate controller static_pages ...
$: command not found
您可能会输入两次。请记住,在Linux上,您不需要每次都输入它。虽然你第二次没有。所以我不知道。
一年前我才开始使用rails。我给你的建议是:
确保您运行的是简易版Linux,例如Ubuntu或Mint。 使用RVM安装。完全按照教程。熟悉终端&amp; amp;贝壳。 老实说,这看起来像某种配置错误。
我认为您的问题与使用生成控制器的命令无关,而是在教程的后面。
我建议深吸一口气,慢慢地回顾一下教程中的步骤。我认为这只是一个配置问题。 (只是我在猜测。)保持冷静,玩得开心吧!