简体   繁体   中英

Rails mountable Engine + Devise

I am doing Authentication app using Devise (as Engine). I followed the steps from this link every thing goes perfectly until i reach the command

rails generate devise MODEL

from the above link after this command it shows some errors

invoke  active_record
 create    db/migrate/20140901111733_devise_create_fd_users.rb
/Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activerecord-4.1.5/lib/active_record/connection_adapters/abstract/connection_pool.rb:541:in `retrieve_connection': ActiveRecord::ConnectionNotEstablished (ActiveRecord::ConnectionNotEstablished)
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:113:in `retrieve_connection'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activerecord-4.1.5/lib/active_record/connection_handling.rb:87:in `connection'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.3.0/lib/generators/active_record/devise_generator.rb:86:in `postgresql?'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.3.0/lib/generators/active_record/devise_generator.rb:78:in `inet?'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.3.0/lib/generators/active_record/devise_generator.rb:74:in `ip_column'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.3.0/lib/generators/active_record/devise_generator.rb:56:in `migration_data'
    from (erb):4:in `migration_template'
    from /Users/user/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/erb.rb:838:in `eval'
    from /Users/user/.rvm/rubies/ruby-1.9.3-p547/lib/ruby/1.9.1/erb.rb:838:in `result'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/migration.rb:64:in `block in migration_template'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `call'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:53:in `render'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block (2 levels) in invoke!'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `open'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:62:in `block in invoke!'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `call'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/empty_directory.rb:116:in `invoke_with_conflict_check'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions/create_file.rb:60:in `invoke!'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/actions.rb:94:in `action'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/migration.rb:34:in `create_migration'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators/migration.rb:63:in `migration_template'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/devise-3.3.0/lib/generators/active_record/devise_generator.rb:16:in `copy_devise_migration'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:115:in `invoke'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:277:in `block in _invoke_for_class_method'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/shell.rb:68:in `with_padding'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:266:in `_invoke_for_class_method'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:149:in `_invoke_from_option_orm'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `block in invoke_all'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `each'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `map'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/invocation.rb:133:in `invoke_all'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/group.rb:232:in `dispatch'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/generators.rb:157:in `invoke'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/commands/generate.rb:11:in `<top (required)>'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `block in require'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:232:in `load_dependency'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/activesupport-4.1.5/lib/active_support/dependencies.rb:247:in `require'
    from /Users/user/.rvm/gems/ruby-1.9.3-p547/gems/railties-4.1.5/lib/rails/engine/commands.rb:19:in `<top (required)>'
    from bin/rails:12:in `require'
    from bin/rails:12:in `<main>'

I thought Database connection not established properly so i tested using the command

rails generate model Test name:string email:string

its working properly, then i gave

rake db:migrate

Now database also migrated successfully, so i think database connection is properly working. The commands mentioned above were run from Engine's Directory. If any information needed comment it out i will provide the details. Thanks

使用devise 3.2.x代替devise 3.3.x

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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