ruby on rails - Pundit Authorization for Basic Proposal Class -


i trying add authorization via pundit proposal class.

i have creation of proposals, etc set have several states aasm_gem proposals. drafted, published , closed.

i want users own proposal able view drafted proposal. on publish users should able view proposal.

how go creating pundit policy achieves this? not able quite understand documentaiton. if can see 1 example should able figure out.

i trasition between states on show page:

<%= button_to 'publish proposal', proposals_publish_path(@proposal), method: :put, class:"pull-right btn btn-primary btn-lg", style:"color:white; border: 0px; margin-top:15px;" %> 

i installed pundit , ran generator.

i don't know aasm_gem you're referring to, description, work (i'm making published? , draft? methods since don't know actual api you're dealing with)

def show?   return true if record.published?   return true if record.draft? && user.id == record.user_id    false end 

Comments

Popular posts from this blog

c# - Binding a comma separated list to a List<int> in asp.net web api -

Delphi 7 and decode UTF-8 base64 -

html - Is there any way to exclude a single element from the style? (Bootstrap) -