【问题标题】:Devise not working with rails. (Undefined local variable or method `‘devise’' for Gemfile)设计不使用rails。 (Gemfile 的未定义局部变量或方法“设计”)
【发布时间】:2014-04-10 10:34:39
【问题描述】:

完成 gem install devise 后,我已将 gem 'devise' 添加到 gem 文件中。

运行 bundle install 时出现以下错误:

Undefined local variable or method'devise'' 用于 Gemfile。`

我的 Gemfile 看起来像这样:

source 'http://rubygems.org'

gem 'mysql'


gem 'rails', '4.0.4'

gem ’devise’

当我删除 gem devise bundle install 时,我会收到错误 undefined local variable or method devise for Gemfile。

【问题讨论】:

  • Gemfile 上的语法很好。只是捆绑安装不起作用,我收到了错误,说未定义 Gemfile 的局部变量或方法。
  • 删除“设计”并重试。请发布 gemfile 的内容和错误日志。
  • 请将您的整个 gemfile 添加到问题中。
  • 它可以在没有 gem 设计的情况下工作,但我想对 rails 使用 devise 身份验证,我必须将 gem 设计添加到 gem 文件中。
  • 好吧,在我按下 ctrl 键的同时键入引号之后,单引号现在看起来很好,并且捆绑安装工作正常。感谢您的关注!

标签: ruby-on-rails ruby-on-rails-4 devise gemfile


【解决方案1】:

如果您在 Mac OSX 上使用 TextEdit,您可能需要确保在您的首选项下未选中智能引号。这将根据程序将您的撇号和引号更新为“适合印刷”的内容。您正在输入单个刻度线/主要标记 (U+2027) 并将其转换为撇号 (U+2032)。或者,您可以在按住引号的同时按住 ctrl 键以获取非倾斜刻度线。我刚刚花了 20 分钟处理同样的问题。

【讨论】:

  • 谢谢!上帝,这是一个非常令人沮丧的问题。
【解决方案2】:

您的 Gemfile 应如下所示

宝石文件:

source 'https://rubygems.org'
gem 'rails', '4.0.2'
gem 'devise'

【讨论】:

  • 确实是这样的。
  • 我确定我使用了单引号键而不是反引号。 ` - backtick ' - Gemfile 上的单引号它是 gem 'device'。
猜你喜欢
  • 1970-01-01
  • 2013-07-28
  • 2015-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2011-07-24
  • 1970-01-01
  • 2019-03-17
相关资源
最近更新 更多