app/controllers/djr_controller.rb in djr-0.0.1 vs app/controllers/djr_controller.rb in djr-0.0.2beta
- old
+ new
@@ -16,14 +16,19 @@
route_str << "#{controller_name} = function(){DJR.call(this);}; #{controller_name}.prototype.routes = {};"
}.compact.join
js << routes.map { |route|
method = route.conditions[:request_method].present? ? route.conditions[:request_method].source[1..-2] : "GET"
- controller_name = "#{route.defaults[:controller].camelize.gsub(/\:\:/, '.')}Controller"
- " #{controller_name}.prototype.routes['#{route.defaults[:action]}'] = {url: \"#{route.path}\", method: \"#{method}\" };"
+ route.defaults[:controller].present? ? mount_js(route) : nil
}.compact.join
render :text => js.to_s
+ end
+
+ private
+ def mount_js route
+ controller_name = "#{route.defaults[:controller].camelize.gsub(/\:\:/, '.')}Controller"
+ " #{controller_name}.prototype.routes['#{route.defaults[:action]}'] = {url: \"#{route.path}\", method: \"#{method}\" };"
end
end
\ No newline at end of file