我正在尝试为新的rails项目生成页面,但我一直收到此错误。
$ rails generate controller pages home
/Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load':/Users/reidwahlbrink/Desktop/Hanna's Blog/config/initializers/session_store.rb:3: syntax error, unexpected tIDENTIFIER, expecting end-of-input
...re, key: '_Hanna's_Blog_session'
... ^ (SyntaxError)
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `block in load'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:232:in `load_dependency'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/dependencies.rb:241:in `load'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/engine.rb:648:in `block in load_config_initializer'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/activesupport-4.1.4/lib/active_support/notifications.rb:161:in `instrument'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/engine.rb:647:in `load_config_initializer'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/engine.rb:612:in `block (2 levels) in <class:Engine>'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/engine.rb:611:in `each'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/engine.rb:611:in `block in <class:Engine>'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `instance_exec'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:30:in `run'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:55:in `block in run_initializers'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:226:in `block in tsort_each'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:348:in `block (2 levels) in each_strongly_connected_component'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:418:in `block (2 levels) in each_strongly_connected_component_from'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:427:in `each_strongly_connected_component_from'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:417:in `block in each_strongly_connected_component_from'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:44:in `each'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:44:in `tsort_each_child'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `call'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:411:in `each_strongly_connected_component_from'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:347:in `block in each_strongly_connected_component'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `call'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:345:in `each_strongly_connected_component'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:224:in `tsort_each'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/tsort.rb:205:in `tsort_each'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/initializable.rb:54:in `run_initializers'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/railties-4.1.4/lib/rails/application.rb:300:in `initialize!'
from /Users/reidwahlbrink/Desktop/Hanna's Blog/config/environment.rb:5:in `<top (required)>'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:92:in `require'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:92:in `preload'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:140:in `serve'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:128:in `block in run'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `loop'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application.rb:122:in `run'
from /Users/reidwahlbrink/.rvm/gems/ruby-2.1.2/gems/spring-1.1.3/lib/spring/application/boot.rb:18:in `<top (required)>'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from /Users/reidwahlbrink/.rvm/rubies/ruby-2.1.2/lib/ruby/2.1.0/rubygems/core_ext/kernel_require.rb:55:in `require'
from -e:1:in `<main>'
我也试过运行rails服务器,它会加载服务器然后退出并返回同样的错误。我正在通过One Month Rails工作,并试图用看到创建更多页面课程后到目前为止学到的东西建立我自己的项目。请帮忙!
答案 0 :(得分:3)
你需要逃避你的撇号'_Hanna\'s_Blog_session'
或者您可以使用双引号"_Hanna's_Blog_session"
原因是在单引号的情况下,您需要确定撇号是字符串文字的一部分而不是字符串的结尾。
答案 1 :(得分:2)
您的应用程序路径中有空格和单引号:
/Users/reidwahlbrink/Desktop/Hanna's Blog/
^ ^
可能来自跑步:
rails new "Hanna's Blog"
这将导致许多问题。您应该删除该目录,而不是运行:
rails new hannasblog