I have these two models:
class Photo < ActiveRecord::Base
belongs_to :user
end
class User < ActiveRecord::Base
has_many :photos
end
and this set up of declarative_authorization
for a role:
role :reg_ser do
has_permission_on :photos, :to => [:show] do
if_attribute :user_id => is { user.id }
end
end
and I want to allow display to user the image that he upload - only his images. I mean, for example:
user_id | photo
1 | 1
1 | 2
1 | 3
2 | 4
And when the user set the url /photos/1
, so this image will be displayed only for user_id
with the number 1
, when the user_id=2
will display this address, he don't see the image...
Is possible something like this to do?