Hi folks,
I'm struggling to put together a permission system required for
transitions on one of my models.
The app needs to allow users to create quotes, and then change the
state of a quote, if they have access to do this.
Access is determined from a integer value in the 'acl_group' Model,
which each user belongs to. This is loosely based on the linux
permission system i.e.
0=no access,
1=create quotes + read/update quotes they own,
2= create quotes + read/update ALL quotes
3 = same as level 2 but can delete quotes
My simplified models are below:
Model User
belongs_to :acl_group
has_many :quote
Model acl_group
quote :integer
has_many :user
Model quote
belongs_to :user
lifecycle do
state :quoted, :default => true
state :won
create :make_quote, :become => :quoted do end
transition :won, {:quoted => :won}, :available_to =>
"acting_user.administrator || acting_user.acl_group.quote > 1 ||
acting_user.acl_group.quote = 1 && acting_user == user"
end
I've tried using the String option, which never grants access and also
tried a code-block which didn't appear to work (I couldn't get past a
'ERROR NameError: undefined local variable or method' error, putting
the code block either in the controller or model (within lifecycle
block and outside).
I trust that I am probably missing something very obvious here, or
maybe just approaching this in the wrong way?
Thanks in advance,
Paul
--
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.