Hi I figured out the problem but not sure how to resolve it.
The issue is the following all my user information is stored in the
user table as I mentioned in my previous post. I don't have a
separate table for my Parent and Tutor models so it looks like
ActiveRecord just grabs everything from the users table.
For example in the console executing Tutors.count an Parents.count
returns the same value.
There seems to be no clear way of filter out the appropriate data
based on which sub type is being used or is there? It would be great
if somehow you could initialize the Parent model with some conditions
based on the associated roles/and permissions so that a Parents.find
(:all) only returns parents and not users.
Basically what I'm doing in my non-admin controllers is resolving the
sub type based on roles and permissios assigned to the user (I am
using the restful authentication plugin) using before_filters etc.
Can I modify the way streamlined retrieves the records to do something
similar?
Otherwise I think I will have to change my STI model to look something
like this:
User < AcitveRecord::Base
has_one: user_login :as=>:loginable
UserLogin <ActiveRecord::Base
belongs_to :loginable, :polymorphic => true
Parent <User
#parent specific stuff here
Tutor <User
#tutor specific stuff here
Then I would basically have to modify the generated
Restful_Authentication code to work with UserLogin instead of or in
conjuction with User. I am loathe to do this because I would have to
keep doing this everytime I wanted to take advantage of a new version
of the plugin.
I am still only a couple months into rails/ruby so I am probably
missing a very simple an obvious solution to this problem.
I would appreciate any advice. Thanks