简体   繁体   English

Rails服务器命令错误

[英]error with rails server command

Can you point me to any good resources that show how to connect Sql Server to Rails app (Windows 7)? 您能否指出我一些好的资源,这些资源显示了如何将Sql Server连接到Rails应用程序(Windows 7)?

I have done the following so far: rails new simple_cms –d sqlserver 到目前为止,我已经完成了以下操作: rails new simple_cms –d sqlserver

gem install bundle

rails s

after the last command, this error is thrown: 最后一条命令后,将引发以下错误:

C:\Sites\s_cms>rails s
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `add_order!' for class `Class' (Name
Error)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb:14:in `singletonclass'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb:12:in `inc
luded'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb:145:in `in
clude'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter/core_ext/active_record.rb:145:in `<t
op (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter.rb:3:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/active_record/connection_adapters/sqlserver_adapter.rb:3:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/activerecord-sqlserver-adapter.rb:1:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activerecord-sqlserver-adapter-2.3.8/lib/activerecord-sqlserver-adapter.rb:1:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:76:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:72:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:72:in `block in require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:61:in `each'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler/runtime.rb:61:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/bundler-1.6.1/lib/bundler.rb:132:in `require'
        from C:/Sites/s_cms/config/application.rb:7:in `<top (required)>'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `require'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:79:in `block in server'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `tap'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:76:in `server'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/railties-4.1.1/lib/rails/commands.rb:17:in `<top (required)>'
        from bin/rails:4:in `require'
        from bin/rails:4:in `<main>'

PS: If I use sqlite as a database system, I am able to successfully start the webserver (no error). PS:如果我将sqlite用作数据库系统,则能够成功启动Web服务器(没有错误)。 This probably means there's nothing wrong with my rails installation. 这可能意味着我的rails安装没有任何问题。 I am guessing I might need to add sth to database.yml or write the database user and password somewhere. 我猜我可能需要向s.data.yml添加sth或在某处写入数据库用户和密码。 But how come this is not required with sqlite3? 但是,为什么sqlite3不需要这样做呢? I also found this resource but not sure if still applicable (it refers to rails 2.0, whereas I use rails 4.1.1) http://rubyrailsandwindows.blogspot.de/2008/03/rails-2-and-sql-server-2008-on-windows_24.html - and some of the things there I tried but don't apply. 我也找到了此资源,但不确定是否仍然适用(它指的是Rails 2.0,而我使用Rails 4.1.1) http://rubyrailsandwindows.blogspot.de/2008/03/rails-2-and-sql-server- 2008-on-windows_24.html-以及我尝试过的一些方法,但并不适用。 Thanks in advance. 提前致谢。

Later edit: I also tried rails s after editing the database.yml (from the config folder) to contain: 以后的编辑:编辑了database.yml(来自config文件夹)以包含以下内容后,我还尝试了rails s

development:
  adapter: sqlserver
  encoding: unicode
  database: cms
  pool: 5
  username: guest1
  password: pwd1234%^&^
test:
  adapter: sqlserver
  encoding: unicode
  database: cms
  pool: 5
  username: guest1
  password: pwd1234%^&^
production:
  adapter: sqlserver
  encoding: unicode
  database: cms
  pool: 5
  username: guest1
  password: pwd1234%^&^

(of course, I also created previously a db called cms, and added a user called guest1 with the specified password, then made sure teh credentials worked to connect to the db by mimic-ing network connection from my local Sql Server itself) (当然,我之前还创建了一个名为cms的数据库,并添加了一个具有指定密码的名为guest1的用户,然后通过模仿本地Sql Server本身的网络连接来确保凭据可用于连接到db)

After this new action I get a similar error as above: 执行此新操作后,我得到与上述类似的错误:

C:\Sites\simple_cms>rails s
C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-.1.1/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method': undefined method `add_order!' for class `Class' (Name Error)
        from C:/Ruby193/lib/ruby/gems/1.9.1/gems/activesupport-4.1.1/lib/active_support/core_ext/module/aliasing.rb:32:in `alias_method_chain'
        ...............

This is a known bug with activerecord-sqlserver-adapter . 这是activerecord-sqlserver-adapter的已知错误。 It's being worked on but any fix has not yet been merged into a milestone. 它正在开发中,但尚未将任何修补程序合并为一个里程碑。

It appears the workaround just now is to change your Gemfile to have: 看来目前的解决方法是将您的Gemfile更改为:

gem 'activerecord-sqlserver-adapter', git: 'https://github.com/Desarrollo-CeSPI/activerecord-sqlserver-adapter.git'

Details of the issue are here and the efforts to fix it are here . 这个问题的细节在这里和解决它的努力都在这里

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM