Advertisement
Guest User

routes

a guest
May 10th, 2013
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 0.38 KB | None | 0 0
  1. def base_resources val, scope, args={}
  2.   begin
  3.     "#{scope.camelcase}::StudentsController".constantize
  4.     resources val.to_sym, args.merge(controller: "#{scope}::#{val}")
  5.   rescue
  6.     resources val.to_sym, args.merge(controller: "base::#{val}")
  7.   end
  8. end
  9.  
  10. %w[math english].each do |subject|
  11.   scope "/#{subject}" do
  12.     base_resources "students", subject, only: :index
  13.   end
  14. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement