Rails-4.2 Share view with muliple controllers -


we have model called authorisation join table user , role. when looked @ user point of view (pov) authorisation called endorsement. when looked @ role pov called holder. these implemented using nested resources:

  resources( :users )     resources(  :roles,       :as => 'endorsements',       :controller => 'endorsements' )   end    resources( :roles )     resources( :users,       :as => 'holders',       :controller => 'holders' )   end 

we need maintain authorisations directly. need maintain them specific users or roles. have created 3 controllers named, authorisations_controller.rb, endorsements_controller.rb , holders_controller.rb. 3 use same views/authorisations/new|edit|show|index pages since other filter of user or role these identical in nature.

however, when enter views/authorisations/new.html.erb template endorsements_controller.rb submit button causes program control return authorisations_controller rather calling endorsements_controller. there rails-4 idiom allow views shared among controllers , return calling instance?

in endorsementscontroller can either: use redirect_to , set return path , desired flash message, or use responders gem, takes location argument. i.e. respond_with user, location: endorsements_path

more info responders available at:


Comments