I assume you would need to know if
proposal_request.proposals.collect { |p| p.user_id }.include? user.id
so maybe you want something in the ProposalRequest like
def proposed?(user)
proposals.collect { |p| p.user_id }.include? user.id
end
Now I assume that upon creating a Proposal, it already has a belongs_to
relation with the current PorposalRequest, but I am not quite sure of it.
can :create, Proposal |proposal| do
proposal.proposal_request.proposed? user
end
Cheers
ace
On Tuesday, November 13, 2012 7:07:51 PM UTC-4, Stan McFarland wrote:
>
> Hi, RoR newbie here. Fairly new, anyway. :). I have a cancan question
> I'm hoping someone can help me with. I have two models - ProposalRequest
> and Proposal. Each ProposalRequest can have many Proposals, but a given
> user can submit only one Proposal for each ProposalRequest. I can't figure
> out how to define the rule in ability.rb for the create action. Can
> someone help?
>
> Thanks
>
> Stan McFarland
>
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/41cP9_R4wp8J.
For more options, visit https://groups.google.com/groups/opt_out.