Want more features on Pastebin? Sign Up, it's FREE!
Guest

routes

By: a guest on May 10th, 2013  |  syntax: Rails  |  size: 0.38 KB  |  views: 36  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  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
clone this paste RAW Paste Data