首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >执行rails生成控制器后在浏览器中获取LoadError,StaticPages帮助联系人

执行rails生成控制器后在浏览器中获取LoadError,StaticPages帮助联系人
EN

Stack Overflow用户
提问于 2015-02-28 04:35:47
回答 1查看 1.4K关注 0票数 0

我知道在Windows上运行rails有很多问题,但是在我得到一台运行Linux或OSx的新笔记本之前,我不能做很多事情。

这是我随机面对的另一个问题。经过多次尝试和错误之后,我最后一次修复了它,所以我现在已经忘记了如何修复它。以下是我至今所做的事,

  1. 创建一个新的rails应用程序
  2. rails生成控制器StaticPages家庭帮助一切都很好。我看到创建了新的静态页面,但是当我运行rails服务器并访问localhost:3000/ static /home时,我在浏览器响应中看到下面的错误, 在2015-02-28 15:21:13 +1100为127.0.0.1启动GET“/static/home” 'active_record/connection_adapters/sqlite3_adapter'. (无法加载LoadError )M确保config/database.yml中的适配器是有效的。如果使用“mysql”、“mysql 2”以外的适配器,‘'postgresql’或'sqlite3‘向Gemfile中添加必要的适配er gem。):activesupport (4.2.0) lib/active_support /Reliencies.rb:274: in require' activesupport (4.2.0) lib/active\_support/dependencies.rb:274:in块in require’activesupport (4.2.0) lib/ activesupport /cisencies.rb:240:in load\_dependen activesupport (4.2.0) lib/active\_support/dependencies.rb:274:inrequire‘activerecord (4.2.0) load\_dependen activesupport (4.2.0) lib/active\_support/dependencies.rb:274:in 6:in' activesupport (4.2.0) lib/active\_support/dependencies.rb:274:inrequire’activesupport (4.2.0) lib/active_support(4.2.0)/dependencies.rb:274:inblock in requ ire' activesupport (4.2.0) lib/active\_support/dependencies.rb:240:inload_dependen cy‘activesupport (4.2.0) lib/active_support/dependencies.rb:274:inrequire' activerecord (4.2.0) lib/active\_record/connection\_adapters/connection\_specific ation.rb:175:inspec’activerecord (4.2.0) lib/active_record/connection_handling.rb:50:inestablish \_connection' activerecord (4.2.0) lib/active\_record/railtie.rb:120:inblock (2级)在‘activesupport (4.2.0) lib/active_support/lazy_load_hooks.rb:38:ininstance\_ev al' activesupport (4.2.0) lib/active\_support/lazy\_load\_hooks.rb:38:inexecute_hoo k’activesupport (4.2.0) lib/active_support中/lazy_load_hooks.rb:45:inblock in ru n\_load\_hooks' activesupport (4.2.0) lib/active\_support/lazy\_load\_hooks.rb:44:ineach‘activesupport (4.2.0) lib/active_support/lazy_load_hooks.rb:44:inrun\_load\_ho oks' activerecord (4.2.0) lib/active\_record/base.rb:316:in’activerecord (4.2.0) lib/active_record/base.rb:26:in' activerecord (4.2.0) lib/active\_record/migration.rb:384:inconnection‘activerecord (4.2.0)lib/active_support/callbacks.rb:734:in\_run\_call\_callba cks' activesupport (4.2.0) lib/active\_support/callbacks.rb:81:inrun_callbacks‘actionpack (4.2.0) lib/action_dispatch/middleware/callbacks.rb:27:incall' actionpack (4.2.0) lib/action\_dispatch/middleware/reloader.rb:73:incall’actionpack (4.2.0) lib/action_dispatch/middleware/remote_ip.rb:78:incall' actionpack (4.2.0) lib/action\_dispatch/middleware/debug\_exceptions.rb:17:inc all‘actionpack (4.2.0) lib/action_dispatch/middleware/show_exceptions.rb:30:inca ll' railties (4.2.0) lib/rails/rack/logger.rb:38:incall_app‘rack (4.2.0)标记中的lib/rails/rack/logger.rb:20:inblock in call' activesupport (4.2.0) lib/active\_support/tagged\_logging.rb:68:inblock’activesupport (4.2.0) lib/active_support/tagged_logging.rb:26:intagged' activesupport (4.2.0) lib/active\_support/tagged\_logging.rb:68:intagged‘rack (4.2.0) lib/rails/rack/logger.rb:20:incall' actionpack (4.2.0) lib/action\_dispatch/middleware/request\_id.rb:21:incall’rack (1.6.0) lib/rack/methodoverride.rb:22:incall' rack (1.6.0) lib/rack/runtime.rb:18:incall‘activesupport (4.2.0) lib/active_support/缓存/策略/本地_缓存_中间件.rb:28:incall' rack (1.6.0) lib/rack/lock.rb:17:in调用‘actionpack (4.2.0) lib/rails/engine.rb:518:incall' railties (4.2.0) lib/rails/application.rb:164:incall’rack (4.2.0) lib/rails/engine.rb:518:incall' railties (4.2.0) lib/rails/application.rb:164:incall‘rack (1.6.0) lib/rack/lock.rb:17:incall' rack (1.6.0) lib/rack/content\_length.rb:15:incall’ C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:94:in (1.6.0) lib/齿条/处理程序/webrick.rb:89:在service' C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/httpserver.rb:138:in的服务中‘start_thread中的ru n' C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/2.1.0/webrick/server.rb:295:in块’呈现为start_threaderb (1.0ms)呈现C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4 .2.0/lib/action_dispatch/middleware/templates/rescues/_trace.html.erb (5.0ms)呈现C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4 .2.0/lib/action_dispatch/middleware/templates/rescues/_request_and_C:/row/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/actionpack-4 .2.0/lib/action_dispatch/middleware/templates/rescues/diagnostics.html.erb response.html .erb (1.0ms),具有救援/布局(58.0ms)

这里有一个类似的问题,adapter',但是这个解决方案不被提问的人所接受。我也试过了,但对我没有用。

Gemfile

代码语言:javascript
复制
source 'https://rubygems.org'

gem 'rails',                '4.2.0'
gem 'sass-rails',           '5.0.1'
gem 'uglifier',             '2.5.3'
gem 'coffee-rails',         '4.1.0'
gem 'jquery-rails',         '4.0.3'
gem 'turbolinks',           '2.3.0'
gem 'jbuilder',             '2.2.3'
gem 'sdoc',                 '0.4.0', group: :doc

gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw]

group :development, :test do
  gem 'sqlite3',     '1.3.9'
  gem 'byebug',      '3.4.0'
  #gem 'web-console', '2.0.0.beta3'
  gem 'spring',      '1.1.3'
end

group :test do
  gem 'minitest-reporters', '1.0.5'
  gem 'mini_backtrace',     '0.1.3'
  gem 'guard-minitest',     '2.3.1'
end

group :production do
  gem 'pg',             '0.17.1'
  gem 'rails_12factor', '0.0.2'
end

Gemfile.lock

代码语言:javascript
复制
GEM
  remote: https://rubygems.org/
  specs:
    actionmailer (4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      mail (~> 2.5, >= 2.5.4)
      rails-dom-testing (~> 1.0, >= 1.0.5)
    actionpack (4.2.0)
      actionview (= 4.2.0)
      activesupport (= 4.2.0)
      rack (~> 1.6.0)
      rack-test (~> 0.6.2)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    actionview (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
      erubis (~> 2.7.0)
      rails-dom-testing (~> 1.0, >= 1.0.5)
      rails-html-sanitizer (~> 1.0, >= 1.0.1)
    activejob (4.2.0)
      activesupport (= 4.2.0)
      globalid (>= 0.3.0)
    activemodel (4.2.0)
      activesupport (= 4.2.0)
      builder (~> 3.1)
    activerecord (4.2.0)
      activemodel (= 4.2.0)
      activesupport (= 4.2.0)
      arel (~> 6.0)
    activesupport (4.2.0)
      i18n (~> 0.7)
      json (~> 1.7, >= 1.7.7)
      minitest (~> 5.1)
      thread_safe (~> 0.3, >= 0.3.4)
      tzinfo (~> 1.1)
    ansi (1.5.0)
    arel (6.0.0)
    builder (3.2.2)
    byebug (3.4.0)
      columnize (~> 0.8)
      debugger-linecache (~> 1.2)
      slop (~> 3.6)
    celluloid (0.16.0)
      timers (~> 4.0.0)
    coderay (1.1.0)
    coffee-rails (4.1.0)
      coffee-script (>= 2.2.0)
      railties (>= 4.0.0, < 5.0)
    coffee-script (2.3.0)
      coffee-script-source
      execjs
    coffee-script-source (1.9.1)
    columnize (0.9.0)
    debugger-linecache (1.2.0)
    erubis (2.7.0)
    execjs (2.3.0)
    ffi (1.9.6-x86-mingw32)
    formatador (0.2.5)
    globalid (0.3.3)
      activesupport (>= 4.1.0)
    guard (2.12.4)
      formatador (>= 0.2.4)
      listen (~> 2.7)
      lumberjack (~> 1.0)
      nenv (~> 0.1)
      notiffany (~> 0.0)
      pry (>= 0.9.12)
      shellany (~> 0.0)
      thor (>= 0.18.1)
    guard-minitest (2.3.1)
      guard (~> 2.0)
      minitest (>= 3.0)
    hike (1.2.3)
    hitimes (1.2.2-x86-mingw32)
    i18n (0.7.0)
    jbuilder (2.2.3)
      activesupport (>= 3.0.0, < 5)
      multi_json (~> 1.2)
    jquery-rails (4.0.3)
      rails-dom-testing (~> 1.0)
      railties (>= 4.2.0)
      thor (>= 0.14, < 2.0)
    json (1.8.2)
    listen (2.8.5)
      celluloid (>= 0.15.2)
      rb-fsevent (>= 0.9.3)
      rb-inotify (>= 0.9)
    loofah (2.0.1)
      nokogiri (>= 1.5.9)
    lumberjack (1.0.9)
    mail (2.6.3)
      mime-types (>= 1.16, < 3)
    method_source (0.8.2)
    mime-types (2.4.3)
    mini_backtrace (0.1.3)
      minitest (> 1.2.0)
      rails (>= 2.3.3)
    mini_portile (0.6.2)
    minitest (5.5.1)
    minitest-reporters (1.0.5)
      ansi
      builder
      minitest (>= 5.0)
      ruby-progressbar
    multi_json (1.10.1)
    nenv (0.2.0)
    nokogiri (1.6.6.2-x86-mingw32)
      mini_portile (~> 0.6.0)
    notiffany (0.0.6)
      nenv (~> 0.1)
      shellany (~> 0.0)
    pg (0.17.1-x86-mingw32)
    pry (0.10.1-x86-mingw32)
      coderay (~> 1.1.0)
      method_source (~> 0.8.1)
      slop (~> 3.4)
      win32console (~> 1.3)
    rack (1.6.0)
    rack-test (0.6.3)
      rack (>= 1.0)
    rails (4.2.0)
      actionmailer (= 4.2.0)
      actionpack (= 4.2.0)
      actionview (= 4.2.0)
      activejob (= 4.2.0)
      activemodel (= 4.2.0)
      activerecord (= 4.2.0)
      activesupport (= 4.2.0)
      bundler (>= 1.3.0, < 2.0)
      railties (= 4.2.0)
      sprockets-rails
    rails-deprecated_sanitizer (1.0.3)
      activesupport (>= 4.2.0.alpha)
    rails-dom-testing (1.0.5)
      activesupport (>= 4.2.0.beta, < 5.0)
      nokogiri (~> 1.6.0)
      rails-deprecated_sanitizer (>= 1.0.1)
    rails-html-sanitizer (1.0.1)
      loofah (~> 2.0)
    rails_12factor (0.0.2)
      rails_serve_static_assets
      rails_stdout_logging
    rails_serve_static_assets (0.0.4)
    rails_stdout_logging (0.0.3)
    railties (4.2.0)
      actionpack (= 4.2.0)
      activesupport (= 4.2.0)
      rake (>= 0.8.7)
      thor (>= 0.18.1, < 2.0)
    rake (10.4.2)
    rb-fsevent (0.9.4)
    rb-inotify (0.9.5)
      ffi (>= 0.5.0)
    rdoc (4.2.0)
      json (~> 1.4)
    ruby-progressbar (1.7.1)
    sass (3.4.13)
    sass-rails (5.0.1)
      railties (>= 4.0.0, < 5.0)
      sass (~> 3.1)
      sprockets (>= 2.8, < 4.0)
      sprockets-rails (>= 2.0, < 4.0)
      tilt (~> 1.1)
    sdoc (0.4.0)
      json (~> 1.8)
      rdoc (~> 4.0, < 5.0)
    shellany (0.0.1)
    slop (3.6.0)
    spring (1.1.3)
    sprockets (2.12.3)
      hike (~> 1.2)
      multi_json (~> 1.0)
      rack (~> 1.0)
      tilt (~> 1.1, != 1.3.0)
    sprockets-rails (2.2.4)
      actionpack (>= 3.0)
      activesupport (>= 3.0)
      sprockets (>= 2.8, < 4.0)
    sqlite3 (1.3.9-x86-mingw32)
    thor (0.19.1)
    thread_safe (0.3.4)
    tilt (1.4.1)
    timers (4.0.1)
      hitimes
    turbolinks (2.3.0)
      coffee-rails
    tzinfo (1.2.2)
      thread_safe (~> 0.1)
    tzinfo-data (1.2015.1)
      tzinfo (>= 1.0.0)
    uglifier (2.5.3)
      execjs (>= 0.3.0)
      json (>= 1.8.0)
    win32console (1.3.2-x86-mingw32)

PLATFORMS
  x86-mingw32

DEPENDENCIES
  byebug (= 3.4.0)
  coffee-rails (= 4.1.0)
  guard-minitest (= 2.3.1)
  jbuilder (= 2.2.3)
  jquery-rails (= 4.0.3)
  mini_backtrace (= 0.1.3)
  minitest-reporters (= 1.0.5)
  pg (= 0.17.1)
  rails (= 4.2.0)
  rails_12factor (= 0.0.2)
  sass-rails (= 5.0.1)
  sdoc (= 0.4.0)
  spring (= 1.1.3)
  sqlite3 (= 1.3.9)
  turbolinks (= 2.3.0)
  tzinfo-data
  uglifier (= 2.5.3)

database.yml

代码语言:javascript
复制
# SQLite version 3.x
#   gem install sqlite3
#
#   Ensure the SQLite 3 gem is defined in your Gemfile
#   gem 'sqlite3'
#
default: &default
  adapter: sqlite3
  pool: 5
  timeout: 5000

development:
  <<: *default
  database: db/development.sqlite3

# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
test:
  <<: *default
  database: db/test.sqlite3

production:
  <<: *default
  database: db/production.sqlite3

更新: rails的命令现在正在抛出此异常,

代码语言:javascript
复制
C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-x86-mingw32/l
ib/sqlite3.rb:6:in `require': cannot load such file -- sqlite3/sqlite3_native (L
oadError)
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-
x86-mingw32/lib/sqlite3.rb:6:in `rescue in <top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/sqlite3-1.3.9-
x86-mingw32/lib/sqlite3.rb:2:in `<top (required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `each'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:72:in `block in require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `each'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler/runtime.rb:61:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/bundler-1.7.7/
lib/bundler.rb:133:in `require'
        from C:/RailsInstaller/work/sample_app/config/application.rb:7:in `<top
(required)>'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:78:in `require'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:78:in `block in server'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:75:in `tap'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:75:in `server'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
        from C:/RailsInstaller/Ruby2.1.0/lib/ruby/gems/2.1.0/gems/railties-4.2.0
/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

如果有人能帮我..。

EN

回答 1

Stack Overflow用户

发布于 2015-12-04 11:13:26

问题似乎与您正在使用的sqlite3版本有关。试炼

代码语言:javascript
复制
gem 'sqlite3', '>= 1.3.9'

而不是

代码语言:javascript
复制
gem 'sqlite3', '1.3.9'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/28778134

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档