any_login
any_login copied to clipboard
Multiple models support
Related: https://github.com/igorkasyanchuk/any_login/pull/44
This change will support multiple models.
What I fixed
- Accept multiple model setting by
klass_names
- Display multiple login forms
- Pass class name by
params[:as]
- In controller, find model name by
params[:as]
and login.
Configuration
config.klass_names = ['User', 'Staff']
Demo
https://user-images.githubusercontent.com/33926355/190950814-c81a11da-b758-43c9-ab31-801ae618d805.mov
I checked this behavior at this repository. https://github.com/kenzo-tanaka/rails_sandbox/pull/8
Hello @igorkasyanchuk @rbclark , Could you review this PR ?
It was difficult to resolve conflicts on https://github.com/igorkasyanchuk/any_login/pull/44, so I created this new PR.
@kenzo-tanaka good start, but I have a question, could you please extend at least dummy/devise app with another model? I want to try it on your branch.
Thanks for the reply. I will try it.
@igorkasyanchuk Sorry for the delay in responding.
could you please extend at least dummy/devise app with another model?
I am having trouble understanding how to proceed this.
Do I just create a new model under the test/rails_app/devise
directory and fix the any_login settings?
I am having trouble understanding how to proceed this. Do I just create a new model under the
test/rails_app/devise
directory and fix the any_login settings?
Correct, specifically in the test/rails_apps/devise/app/models
folder. You can set it up the same way it is in your demo with a user and a staff model if you wish.
Thanks for the reply.
Is it possible to use the rails
or rake
commands in the test/rails_app/devise
directory?
I get an error when I run the following commands, is there a workaround?
$ cd test/rails_apps/devise/
$ rails db:create
rails aborted!
NameError: uninitialized constant Bundler
/Users/tanakakenzou/Documents/personal/any_login/test/rails_apps/devise/config/application.rb:7:in `<top (required)>'
/Users/tanakakenzou/Documents/personal/any_login/test/rails_apps/devise/Rakefile:4:in `require_relative'
/Users/tanakakenzou/Documents/personal/any_login/test/rails_apps/devise/Rakefile:4:in `<top (required)>'
bin/rails:4:in `<main>'
Caused by:
LoadError: cannot load such file -- rails/commands
bin/rails:4:in `<main>'
(See full trace by running task with --trace)
Thanks for the reply. Is it possible to use the
rails
orrake
commands in thetest/rails_app/devise
directory?I get an error when I run the following commands, is there a workaround?
You just need to preface your commands with bundle exec
,
➜ devise git:(master) pwd
/Documents/any_login/test/rails_apps/devise
➜ devise git:(master) bundle exec rails db:create
Database 'db/development.sqlite3' already exists
Database 'db/test.sqlite3' already exists
@igorkasyanchuk @rbclark I added a new model to the devise sample app. Please check it.
Thank you @kenzo-tanaka, this is super close to being ready to merge. The only remaining issue is the klass_name
problem.