cancan - Accessing an external table from a Rails application -
rails 3.2
i using api gem. client wants, keep table wants whitelist email addresses can used access api, in seprate table, can access through phpmyadmin.
this single table:
api_users
with single column: email (in addition id, created_at, updated_at)
the email addresses go in table, exist in users table rails application.
if create model: models/api_user.rb:
class apiuser< activerecord::base attr_accessible :email
and, in models/api_ability.rb, add following:
class apiability include cancan::ability def initialize(user, params = {}) user ||= user.new if apiuser.find_by_email(user.email) can :manage, :api end end end
will work?
that sounds absolutely doable. might want add like
def readonly? true end
to apiuser
class make sure no 1 try create instances of within rails. apart don't see reason not way given clients requirements.
Comments
Post a Comment