association extensions - has_one


I'm struggling with something that must be very common pattern, and
want to do it the correct rails/ruby way but am a bit dense !

I have users - an admin user, registered users and a guest user (using

For many of linked associations I want the admin to be able to list or
edit all instances, the registered user only their own one and guest
none at all.

So somehow I want to over ride or extend the associations, or find, so
that the condition is captured in one place and my controller/view
code isn't littered with these same if, else blocks...e.g something


I've tried using the Association extensions so I can simply call
something like

@theme = User.current.theme.find_theme


class User < ActiveRecord::Base

  has_one :theme do
    def find_theme()

But no joy, this gives method missing. If I change the association to
has_many however, it does work - but this is obviously not then
correct with the model.

Do extensions only work for has_many ?

Any advice on best place or pattern to encapsulate this kind of
situation much appreciated.

Many thanks