SHARE
TWEET

routes

a guest May 10th, 2013 45 Never
  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
RAW Paste Data
Top