Skip to content

记录开发mobile_auth的心得 #3

Description

@easyhappy

【ToDo】
记录在开发mobile_auth 和学习devise的过程中的心得!!

1: 初始化mobile_auth这个gem

2: 实现mobile_auth_for :users详细的开发记录

3: 将mobile_auth mount 到 Rails 项目中
运行rails server 会报如下错误:

bin/rails:6: warning: previous definition of APP_PATH was here
Usage: rails COMMAND [ARGS]

解决方法: 代码提交记录
添加warden
修改Engine代码

module MobileAuth
  class Engine < ::Rails::Engine
    # isolate_namespace MobileAuth
    config.devise = MobileAuth #什么用

    # Initialize Warden and copy its configurations.
    config.app_middleware.use Warden::Manager do |config|
      MobileAuth.warden_config = config
    end

    # Force routes to be loaded if we are doing any eager load.
    config.before_eager_load { |app| app.reload_routes! }
  end

这个时候, 在运行rails server, 就会自动 mount engine, 测试命令
测试命令, rake routes, 我们会发现会将 生成对应的route

...
        session POST   /           sessions#create
destroy_session DELETE /           sessions#destroy

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions