I created a simple Ruby on Rails 4 application with a few simple models and a PosgreSQL database that was deployed to my test VPS. Then I created three Devise models using Rails generators.
I selected individual Devise models, as the models are completely different from each other. The unidirectional inheritance method has not been discussed.
I understand that with any Devise model, I can authenticate to the site, register "developed" users, etc. It works.
Now I plan to create a place to do my credentials. I abandoned CanCan as it is not supported by Rails 4 at the moment according to what I found using Google.
Thus, the most suitable option I found is to simply use before_filtermy own authentication method, which, in turn, checks the type current_useror its existence and returns if it is good or not.
Here is an example of the pseudo code I have already tried, and it looks like it works.
before_filter :custom_authentication!
def custom_authentication!
if current_admin
redirect_to "admin_page"
elsif current_monkey
redirect_to "zoo"
elsif current_human
redirect_to "home"
else
end
end
As I understand it, I need to put this code in every controller that I have in my Rails 4 application. Is this correct?
: ? , application_controller.rb, Devise, - . ? ? ?