Rails-NoMethodError:#<FirstApp的未定义方法“ configure”

我正在制作教程,我正在尝试执行步骤1.4.2

我已经尝试了几件事,但是当我在网上搜索“ NoMethodError:未定义的方法'configure'”时,似乎没有任何作用。我查看了所有链接以及出现的一些类似搜索,但均无济于事。

书中说要这样做:

# This should only be used if your Heroku deploy fails without it.
$ rake assets:precompile
$ git add .
$ git commit -m "Add precompiled assets for Heroku"

但是它没有用或者我没有用

这是我做的真正问题

$ git push heroku master

这就是结果。

james@ubuntu:~/rails_projects/first_app$ git push heroku master
Initializing repository, done.
Counting objects: 84, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (73/73), done.
Writing objects: 100% (84/84), 17.47 KiB, done.
Total 84 (delta 16), reused 0 (delta 0)

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-2.0.0
-----> Installing dependencies using 1.5.2
   Running: bundle install --without development:test --path vendor/bundle --binstubs       vendor/bundle/bin -j4 --deployment
   Fetching gem metadata from https://rubygems.org/..........
   Fetching additional metadata from https://rubygems.org/..
   Installing minitest (4.7.5)
   Installing multi_json (1.10.1)
   Installing rake (10.3.2)
   Installing i18n (0.6.9)
   Installing thread_safe (0.3.3)
   Installing builder (3.1.4)
   Installing erubis (2.7.0)
   Installing tzinfo (0.3.39)
   Installing rack (1.5.2)
   Installing mime-types (1.25.1)
   Installing polyglot (0.3.4)
   Installing activerecord-deprecated_finders (1.0.3)
   Installing arel (4.0.2)
   Installing coffee-script-source (1.7.0)
   Installing hike (1.2.3)
   Installing execjs (2.0.2)
   Using bundler (1.5.2)
   Installing thor (0.19.1)
   Installing rails_serve_static_assets (0.0.2)
   Installing tilt (1.4.1)
   Installing rails_stdout_logging (0.0.3)
   Installing sass (3.2.19)
   Installing activesupport (4.0.5)
   Installing rack-test (0.6.2)
   Installing treetop (1.4.15)
   Installing json (1.8.1)
   Installing coffee-script (2.2.0)
   Installing rails_12factor (0.0.2)
   Installing sprockets (2.11.0)
   Installing activemodel (4.0.5)
   Installing jbuilder (1.0.2)
   Installing rdoc (3.12.2)
   Installing actionpack (4.0.5)
   Installing uglifier (2.5.0)
   Installing mail (2.5.4)
   Installing sdoc (0.3.20)
   Installing sprockets-rails (2.0.1)
   Installing activerecord (4.0.5)
   Installing railties (4.0.5)
   Installing actionmailer (4.0.5)
   Installing coffee-rails (4.0.1)
   Installing jquery-rails (3.0.4)
   Installing sass-rails (4.0.3)
   Installing turbolinks (1.1.1)
   Installing rails (4.0.5)
   Installing pg (0.15.1)
   Your bundle is complete!
   Gems in the groups development and test were not installed.
   It was installed into ./vendor/bundle
   Post-install message from rdoc:
   Depending on your version of ruby, you may need to install ruby rdoc/ri data:
   <= 1.8.6 : unsupported
   = 1.8.7 : gem install rdoc-data; rdoc-data --install
   = 1.9.1 : gem install rdoc-data; rdoc-data --install
   >= 1.9.2 : nothing to do! Yay!
   Bundle completed (36.13s)
   Cleaning up the bundler cache.
-----> Writing config/database.yml to read from DATABASE_URL
-----> Preparing app for Rails asset pipeline
   Running: rake assets:precompile
   rake aborted!
   NoMethodError: undefined method `configure' for #  <FirstApp::Application:0x007f74b12b4cb0>
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/config/environments/production.rb:1:in `<top (required)>'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/engine.rb:591:in `block (2 levels) in <class:Engine>'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/engine.rb:590:in `each'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/engine.rb:590:in `block in <class:Engine>'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:30:in `instance_exec'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:30:in `run'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:55:in `block in run_initializers'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:44:in `each'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:44:in `tsort_each_child'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/initializable.rb:54:in `run_initializers'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/application.rb:215:in `initialize!'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/config/environment.rb:5:in `<top (required)>'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `block in require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:214:in `load_dependency'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/activesupport-4.0.5/lib/active_support/dependencies.rb:229:in `require'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/application.rb:189:in `require_environment!'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/railties-4.0.5/lib/rails/application.rb:250:in `block in run_tasks_blocks'
   /tmp/build_be175c11-67be-427d-9e11-526ec2b315c1/vendor/bundle/ruby/2.0.0/gems/sprockets-rails-2.0.1/lib/sprockets/rails/task.rb:54:in `block (2 levels) in define'
   Tasks: TOP => environment
   (See full trace by running task with --trace)
 !
 !     Precompiling assets failed.
 !

 !     Push rejected, failed to compile Ruby app

To [email protected]:shielded-mountain-9814.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to '[email protected]:shielded-mountain-9814.git'
用户3894023

我刚刚在为某人重新格式化后为其设置Rails教程的计算机时遇到了同样的问题。我正在使用RailsInstaller.com Windows可执行文件在Windows 7上安装Rails,但是我想错误的实际原因和解决方案在Linux / OS X上是相同的。

我的问题是当前的RailsInstaller可执行文件安装了Rails 4.1.4(如果可以在安装过程中选择哪个版本,我看不到)。RailsTutorial.org教程旨在与Rails 4.0.8一起使用,至少在Hartl先生对其进行更新之前。

创建first_app项目后,更新项目目录中的Gemfile以使用Rails 4.0.8rails new first_app无法解决该问题,因为该问题发生在生成app / config / initializers / development.rb文件的过程中,默认情况下,使用本地存储库中安装的最新版本的Rails。

我仍然还是Rails的新手,所以我不知道更改了什么或为什么更改了,但是Rails 4.0.8和Rails 4.1.4之间的一些更新导致使用不同的语法生成development.rb(和production.rb)。 。

对这些文件的第一行进行更改以FirstApp::Application.configure.do代替Rails.application.configure.do,如其他人所建议的那样,将解决编译错误。但是,对于每个项目都必须手动更改该行对我来说不合适。

我能够使它以两种不同的方式正确生成文件:

1)创建rails项目,指定要使用的Rails版本(由下划线包围)。例如,rails _4.0.8_ new first_app很明显,您必须安装该版本的Rails才能正常工作。您可以查看使用命令安装的该gem的所有版本gem list -d rails如果没有正确的版本,请使用gem install rails --version 4.0.8它来安装。

2)rails new在启动新项目时,导航到您要从中运行命令的目录,然后从本地gem仓库中手动卸载任何版本的Rails及其高于4.0.8的依赖项。为此,请使用命令gem uninstall <gem name> --version <version number>您也可以不使用version参数而使用该命令,然后使用gem install rails --version 4.0.8之后,它将安装Rails及其依赖项的匹配版本。

这比较耗时,但这是我最终要做的。就我而言,我为此做的工作是actionmailer,actionpack,activemodel,activerecord,activesupport,railsrailties一旦所有这些gem的最高版本为4.0.8,默认情况下将使用Rails 4.0.8生成一个新项目,并使用正确的语法创建development.rb。

对于RVM用户要提的一件事(由于我是在Windows上的,所以我自己不使用它,因此我没有对其进行测试):仔细检查根开发目录中将使用哪个版本的Rails RVM(键入时您将位于的目录rails new,因为这是生成新项目时将使用的版本。即使您将RVM设置为在新项目文件夹中一次使用Rails 4.0.8,也无法解决该问题,因为文件本身仍然是使用根目录中使用的任何版本的Rails RVM生成的。

再说一次,我仍然是Rails的新手,所以希望有人比我能解释Rails 4.0.8和4.1.4之间的development / production.rb发生了什么变化。但是,与此同时,如果您试图为RailsTutorial.org进行设置并遇到此错误,则可以使用以下两种方法来修复它。

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

Rails - NoMethodError: undefined method `configure' for #<FirstApp

来自分类Dev

rails NoMethodError:未定义的方法“酒店”

来自分类Dev

Rails 4:NoMethodError:nil:NilClass的未定义方法“ each”

来自分类Dev

Rails NoMethodError:未定义的方法“紧凑”错误

来自分类Dev

Ruby on Rails NoMethodError“未定义的方法'translates'”

来自分类Dev

rspec-rails + capybara NoMethodError:未定义的方法“创建”

来自分类Dev

Rails NoMethodError(Hyperclient:模块的未定义方法“ new”)

来自分类Dev

Rails类为NoMethodError提供了未定义的方法“ each”

来自分类Dev

Rails DateTime-NoMethodError(nil:NilClass的未定义方法“ []”)

来自分类Dev

Rails:NoMethodError-未定义的方法“保存”

来自分类Dev

Heroku + Rails:NoMethodError(nil:NilClass的未定义方法“ /”)

来自分类Dev

Ruby on Rails Rspec NoMethodError:未定义的方法“ not_to”

来自分类Dev

Android Volley Rails:NoMethodError(““:String”的未定义方法'+ @')

来自分类Dev

Rails延迟作业NoMethodError:未定义的方法`前缀

来自分类Dev

rspec-rails + capybara NoMethodError:未定义的方法“创建”

来自分类Dev

NoMethodError未定义方法FixNum-Rails 4

来自分类Dev

Rails 4错误:NoMethodError-未定义的方法“ itemfavorites”

来自分类Dev

Rails,Omniauth:NoMethodError-未定义的方法“是否持续?”

来自分类Dev

学习 Ruby on Rails:NoMethodError(未定义方法 `[]' for nil:NilClass):

来自分类Dev

Rails NoMethodError(52:Integer 的未定义方法“回复”):

来自分类Dev

Rails NoMethodError:未定义 #<JobClass 的方法“名称”

来自分类Dev

测试我的Ruby gem:Shoulda :: Matchers:Module的未定义方法“ configure”(NoMethodError)

来自分类Dev

homestead.rb:63:in`configure':nil:NilClass的未定义方法`each'(NoMethodError)

来自分类Dev

未定义的方法NoMethodError

来自分类Dev

NoMethodError:未定义的方法

来自分类Dev

NoMethodError未定义的方法

来自分类Dev

Rails-NoMethodError-AccessToFinance:Module的未定义方法“作用域”

来自分类Dev

使用“受保护的属性” gem时出现Rails NoMethodError(未定义方法“ id” ...)

来自分类Dev

Heroku上的Rails 4.0,NoMethodError(#<User的未定义方法`password_digest ='

Related 相关文章

  1. 1

    Rails - NoMethodError: undefined method `configure' for #<FirstApp

  2. 2

    rails NoMethodError:未定义的方法“酒店”

  3. 3

    Rails 4:NoMethodError:nil:NilClass的未定义方法“ each”

  4. 4

    Rails NoMethodError:未定义的方法“紧凑”错误

  5. 5

    Ruby on Rails NoMethodError“未定义的方法'translates'”

  6. 6

    rspec-rails + capybara NoMethodError:未定义的方法“创建”

  7. 7

    Rails NoMethodError(Hyperclient:模块的未定义方法“ new”)

  8. 8

    Rails类为NoMethodError提供了未定义的方法“ each”

  9. 9

    Rails DateTime-NoMethodError(nil:NilClass的未定义方法“ []”)

  10. 10

    Rails:NoMethodError-未定义的方法“保存”

  11. 11

    Heroku + Rails:NoMethodError(nil:NilClass的未定义方法“ /”)

  12. 12

    Ruby on Rails Rspec NoMethodError:未定义的方法“ not_to”

  13. 13

    Android Volley Rails:NoMethodError(““:String”的未定义方法'+ @')

  14. 14

    Rails延迟作业NoMethodError:未定义的方法`前缀

  15. 15

    rspec-rails + capybara NoMethodError:未定义的方法“创建”

  16. 16

    NoMethodError未定义方法FixNum-Rails 4

  17. 17

    Rails 4错误:NoMethodError-未定义的方法“ itemfavorites”

  18. 18

    Rails,Omniauth:NoMethodError-未定义的方法“是否持续?”

  19. 19

    学习 Ruby on Rails:NoMethodError(未定义方法 `[]' for nil:NilClass):

  20. 20

    Rails NoMethodError(52:Integer 的未定义方法“回复”):

  21. 21

    Rails NoMethodError:未定义 #<JobClass 的方法“名称”

  22. 22

    测试我的Ruby gem:Shoulda :: Matchers:Module的未定义方法“ configure”(NoMethodError)

  23. 23

    homestead.rb:63:in`configure':nil:NilClass的未定义方法`each'(NoMethodError)

  24. 24

    未定义的方法NoMethodError

  25. 25

    NoMethodError:未定义的方法

  26. 26

    NoMethodError未定义的方法

  27. 27

    Rails-NoMethodError-AccessToFinance:Module的未定义方法“作用域”

  28. 28

    使用“受保护的属性” gem时出现Rails NoMethodError(未定义方法“ id” ...)

  29. 29

    Heroku上的Rails 4.0,NoMethodError(#<User的未定义方法`password_digest ='

热门标签

归档