Rails 3.0.9 と認証用のデバイスを使用しています。ポリモーフィズムを使用する必要があるため、単一テーブルの継承を使用しようとしているため、User クラスから継承する UserType1 と UserType2 の 2 つのクラスがあります。ユーザーのタイプに応じて、そのDeviseインスタンスが current_user を正しく必要とします。
例えば、
class User < ActiveRecord::Base
#devise and other user logic
end
class UserType1 < User
def get_some_attribute
return "Hello, my type is UserType1"
end
end
class UserType2 < User
def get_some_attribute
return "Hello, my type is UserType2"
end
end
In controller
class MyController < ApplicationController
def action
@message = current_user.get_some_attribute #depending the type using polymorphism
render :my_view
end
end