I wish to create a polymorphic class (User) as a particular type and use it later with conditions depending on the type of object.
class SuperUser < User
class Admin < User
class User
@user = @account.users.new(params[:user])
This will create a user as a User object. Only way I can think of creating and using @user as a particular type of object is by doing something like this:
@user = Admin.new(params[:user]) if params[:user][:type] == "Admin"
@user = SuperUser.new(params[:user]) if params[:user][:type] == "SuperUser"
@user.account = @account
if @user.is_a? Admin
...
end
....
So, is there a better way to do this?
You can define
polymorphic_newclass method for UserAnd then in controller
I’m not concerned the security question though..