W dniu 15.07.2010 08:26, Gigg pisze:
> Hi,
>
> I am still new to hobo and loving it. But I have come unstuck and cant
> find an answer so I was hoping someone could help.
>
> I have a user, contract, smartcard and device models. What I want to
> do is allow a user to login and only see their contract, device and
> smartcard. But, I cant figure out how to make it happen. Each user can
> login and see all contracts, smartcards and devices which is not what
> I want.
>
> The relationships are:
>
> User
>
> has_many :contract_assignments, :dependent => :destroy
> has_many :contracts, :class_name => "Contract", :foreign_key =>
> "owner_id"
> has_many :contracts, :through => :contract_assignments
>
> contract
>
> belongs_to :owner, :class_name => "User", :creator => true
> has_many :smartcards, :dependent => :destroy
> has_many :devices, :dependent => :destroy
> has_many :contract_assignments, :dependent => :destroy
>
> smartcard
> belongs_to :contract
>
> device
> belongs_to :contract
>
> I just added this in user:
> has_many :contracts, :class_name => "Contract", :foreign_key =>
> "owner_id"
You probably want something like
index_action :my_contracts
def my_contracts
# this will list owned contracts for signed up user
# and all contracts for Guest
hobo_index current_user.try.contracts
end
and proper permissions (only owner can see, edit, create etc.). See
http://cookbook.hobocentral.net/manual/controllers#index_actions
http://cookbook.hobocentral.net/manual/permissions
Joachim
--
You received this message because you are subscribed to the Google Groups "Hobo
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/hobousers?hl=en.