1.我使用ruby-2.0.0 rails-4.0
2.我按照教程http://ruby.railstutorial.org/chapters/static-pages#top
3.我運行了「bundle install」命令。
4.Here是輸出「包安裝」命令如何生成Staticpages控制器?
[email protected]:~/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.Next我跑這個命令
「$軌生成器StaticPages家庭幫助--no測試框架」。
輸出一定是如圖所示根據教程
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/[email protected]_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/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/[email protected]/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/[email protected]_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/[email protected]_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.我試圖與本教程中的下一個命令「$軌生成控制器static_pages ...「,爲此必須生成一個名爲」static_pages_controller.rb「的控制器。
的輸出「$軌生成器static_pages ......」是
/home/user/.rvm/gems/[email protected]_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/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/[email protected]/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/[email protected]_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/[email protected]_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>'
[email protected]:~/rais_project/sample_app$ clear
[email protected]:~/rais_project/sample_app$ $ rails generate controller static_pages ...
$: command not found
[email protected]:~/rais_project/sample_app$ rails generate controller static_pages ...
/home/user/.rvm/gems/[email protected]_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/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:6:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:5:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers/erb.rb:4:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template/handlers.rb:10:in `extended'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `extend'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:97:in `<class:Template>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:7:in `<module:ActionView>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/actionpack-4.0.3/lib/action_view/template.rb:5:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder_template.rb:56:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `require'
from /home/user/.rvm/gems/[email protected]_rails_4_0/gems/jbuilder-1.0.2/lib/jbuilder.rb:340:in `<top (required)>'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:72:in `block in require'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `each'
from /home/user/.rvm/gems/[email protected]/gems/bundler-1.5.2/lib/bundler/runtime.rb:61:in `require'
from /home/user/.rvm/gems/[email protected]/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/[email protected]_rails_4_0/gems/railties-4.0.3/lib/rails/commands.rb:43:in `require'
from /home/user/.rvm/gems/[email protected]_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>'
但這種控制器不generated.Can請你幫忙嗎?
的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
'bundle exec rails生成控制器StaticPages home help --no-test-framework'? –
我執行了這個命令,但沒有生成控制器 – user3355409
你的錯誤實際上是在這裏給出的:'未初始化的常量Erubis(NameError)'。發佈您的Gemfile並可能編輯該問題以查看是否有人可以提供幫助。快速谷歌顯示它可能是與傾斜寶石。 – 2014-02-26 13:56:29