def base_resources val, scope, args={}
begin
"#{scope.camelcase}::StudentsController".constantize
resources val.to_sym, args.merge(controller: "#{scope}::#{val}")
rescue
resources val.to_sym, args.merge(controller: "base::#{val}")
end
end
%w[math english].each do |subject|
scope "/#{subject}" do
base_resources "students", subject, only: :index
end
end