ruby - Rails route parent ID name and CanCan issue -


i'm trying simple route working

/agenda_items/5/feed 

to this, have following route setup

resources :agenda_items   member    "/feed", to: "comments#feed"   end end 

in each of controllers, i'm using cancan handle authentication , works fine, on 1 action i'm having issue, i'm pretty sure down railsnaming generation. when runrake routes`, route above produced

feed_agenda_item        /agenda_items/:id/feed(.:format)                     agenda_items/:id#feed 

as far can tell, cancan expecting :id parameter, :agenda_item_id result, parent resource isn't being loaded.

is there way can rails change cancan work without me having manually load , authorize resource, or there way can cancan change it's looking on actions?

the problem routes wrong. try create member action agenda items routes comments controller. if want feed of commments single agenda item should this:

resources :agenda_items   resources :comments     collection       :feed     end   end end 

you should following when running rake routes:

feed_agenda_item_comments      /agenda_items/:agenda_item_id/feed(.:format)                     comments#feed 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -