English 中文(简体)
A. 铁路模型的形成过程中的协同效应
原标题:Syntax error when creating a Rails model

我正在利用指挥手段,在铁路3中建立汽车模型:

rails generate model Car name:string id_str:string

但我想到的是错误:

/home/XX/.rvm/gems/ruby-1.9.2-p290/gems/activesupport-3.1.1/lib/active_support/dependencies.rb:234:in `load : /home/XX/myapp/config/initializers/session_store.rb:3: syntax error, unexpected  : , expecting $end (SyntaxError)
...sion_store :cookie_store, key:  _myapp_session 

为什么?

我的<代码>session_store.rb

Myapp::Application.config.session_store :cookie_store, key:  _myapp_session 

What s wrong with 我的<代码>session_store.rb?

问题回答

这种错误通常发生在你试图使用Rubyi <的1.9.2 Hash syntax时;1.9。

在Rub.1.9.2,以下法典完全有效。

Myapp::Application.config.session_store :cookie_store, key:  _myapp_session 

在Rublt,1.9人必须使用

Myapp::Application.config.session_store :cookie_store, :key =>  _myapp_session 

这是奇怪的,因为你的 st痕追踪了Rub.1.9.2。 你们是否相信你会与Rub.1.9.2管理发电机?

无论如何,您可将<代码>session_store.rb文档转换到alh-rocket syntax。 如果它发挥作用,就意味着你不使用Rub1.9.2,并且你重复了错误的信息。

我最后做的是:

for x in `gem list --no-versions`; do sudo gem uninstall $x; done

这迫使所有旧的宝石都被拆除。 我随后着手核实了灰色环境,以证实 g正在使用正确的废墟:

sudo gem env

出现错误的原因是,铁路仍在试图使用1.8瓦 rub,造成各种问题。

一旦上述所有措施得到适当监督:

sudo gem update --system
sudo gem install rubygems-update
sudo update_rubygems

这将确保你达到最新版本。 然后:

sudo gem install rails

这将安装你所需要的一切。 我掌握着所有象牙那样的宝子,以确保我的根安装经过适当的配置/安装。

你们最后要看一下:

RubyGems Environment:
  - RUBYGEMS VERSION: 1.8.13
  - RUBY VERSION: 1.9.3 (2011-10-30 patchlevel 0) [x86_64-darwin10.8.0]
  - INSTALLATION DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1
  - RUBY EXECUTABLE: /usr/local/Cellar/ruby/1.9.3-p0/bin/ruby
  - EXECUTABLE DIRECTORY: /usr/local/Cellar/ruby/1.9.3-p0/bin
  - RUBYGEMS PLATFORMS:
    - ruby
    - x86_64-darwin-10
  - GEM PATHS:
     - /usr/local/Cellar/ruby/1.9.3-p0/lib/ruby/gems/1.9.1

<>strong>TL;DR:uninstall 然后重整铁路。

在您的项目目录中,如果您在<条码>中打字,那么你会看到什么? 关于地雷,我看到<代码>/usr/bin/rails。 这使我感到可以起诉的是,它使用错误的<条码>铁路/条码>。 如果我想到我的<条码>$PATH,我可以看到,RVERS双向(/Users/ramon/.rvm/gems/ruby-1.9.3-p194/bin) 不含<条码>铁路文档(关于如何删除条码——我没有子)。 因此,我的系统照搬了<代码>/usr/bin/rails。

在考察铁路来源时,我看到<条码>铁路/条码>灰有<条码>铁路/条码>。 I uninsated railties (gem uninstall railties), 然后又重新插入。 Voila - which rails show /Users/ramon/.rvm/gems/ruby-1.9.3-p194/bin/rails

我得以解决这个问题,在我的申请中添加了卷宗。

echo "rvm ruby-2.0.0@rails32 --create" > .rvmrc

我解决这一问题,删除了我的微薄的目录,并重新安装了低频仪器。

真正的奇怪问题,因为错误是自我解释

你们在本档案中有一些我,而且没有最后声明。

`load : /home/XX/myapp/config/initializers/session_store.rb:3




相关问题
rails collection_select vs. select

collection_select and select Rails helpers: Which one should I use? I can t see a difference in both ways. Both helpers take a collection and generates options tags inside a select tag. Is there a ...

SSL slowness in EC2

We ve deployed our rails app to EC2. In our setup, we have two proxies on small instances behind round-robin DNS. These run nginx load balancers for a dynamically growing and shrinking farm of web ...

Auth-code with A-Za-z0-9 to use in an URL parameter

As part of a web application I need an auth-code to pass as a URL parameter. I am currently using (in Rails) : Digest::SHA1.hexdigest((object_id + rand(255)).to_s) Which provides long strings like : ...

RubyCAS-Client question: Rails

I ve installed RubyCAS-Client version 2.1.0 as a plugin within a rails app. It s working, but I d like to remove the ?ticket= in the url. Is this possible?

activerecord has_many :through find with one sql call

I have a these 3 models: class User < ActiveRecord::Base has_many :permissions, :dependent => :destroy has_many :roles, :through => :permissions end class Permission < ActiveRecord::...

Ordering a hash to xml: Rails

I m building an xml document from a hash. The xml attributes need to be in order. How can this be accomplished? hash.to_xml

Text Editor for Ruby-on-Rails

guys which text editor is good for Rubyonrails? i m using Windows and i was using E-Texteditor but its not free n its expired now can anyone plese tell me any free texteditor? n which one is best an ...

How to get SQL queries for each user where env is production

I’m developing an application dedicated to generate statistical reports, I would like that user after saving their stat report they save sql queries too. To do that I wrote the following module: ...

热门标签