redirect users by the tables that they belong to

I have two tables: workers_table and admins_table.

I have two controllers and I use devise (sign_in, sign_up...).

I use:

before_filter :authenticate_user!

in the controllers of workers and admins.

assume I have the email of the user that signed in:

@email =

I want to check where @email is found:

if it's found in the workers table, so redirect him to the index.html.erb of workers (and he can't enter to index.html.erb of the admins).

if it's found in the admins table, so redirect him to the index.html.erb of admins (and he can't enter to index.html.erb of the workers).

I know how to check if the user belongs to workers_table or admins_table.

but where should I check which table the user belongs to? should I define another controller?

please guide me.


application_controller.rb would be a good place to define the authenticate_user functionality

another place could be a sessions_controller.rb if you have it

at the very least you could have an ensure_admin method for your admins_controller to add to the before_filter, and if they are not an admine, you could redirect_to workers#index

I'm new to rails, so i'm unsure as to the conventional way to do this, but the above is how I might do it.

Need Your Help

AngularJS ng-src and ng-attr-src don't work in IMG tag

angularjs image binding src

I'm attempting to load an image from a URL in data being returned from MongoDB. On my user's profile editing page, they can edit certain details like their email address, and their user profile ima...

How can I remove a set of data from my results from my response from an API?

php html

I have a page here that if you sort by color or size (click on the headers) we have some data that is uncategorized. How can I filter this out? Would it be something similar to the $activeonly code...

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.