{"id":379,"date":"2007-11-08T17:18:01","date_gmt":"2007-11-08T21:18:01","guid":{"rendered":"http:\/\/www.dr-chuck.com\/wordpress\/?p=379"},"modified":"2011-12-17T12:24:11","modified_gmt":"2011-12-17T16:24:11","slug":"what-is-tough-in-java-servlets-is-easy-in-ruby-rails","status":"publish","type":"post","link":"https:\/\/www.dr-chuck.com\/csev-blog\/2007\/11\/what-is-tough-in-java-servlets-is-easy-in-ruby-rails\/","title":{"rendered":"What is tough in Java Servlets is Easy in Ruby \/ Rails"},"content":{"rendered":"<p>I am amazed at the flexibility of Rails.  I needed a way to dispatch between the portal and a tool and communicate which &#8220;context&#8221; \/ &#8220;site&#8221; the tool is supposed to operate in.<br \/>\nIn Sakai we have complex stuff like a request filter and obtuse code buried in portal to accomplish this.<br \/>\nIn Ruby it is trivial&#8230;<\/p>\n<p><!--more--><br \/>\nIn my portal&#8217;s view &#8211; I add this line:<br \/>\n<%= link_to_remote 'Users', :update=> &#8216;main-content&#8217;,<br \/>\n:url => { :action => &#8216;ajaxstart&#8217;, :controller=>&#8217;users&#8217;,<br \/>\n:div => &#8216;main-content&#8217;, :context => 1} %><br \/>\nThe context is the site id.<br \/>\nIn my routes.rb file it looks like this:<br \/>\nmap.connect &#8221;, :controller => &#8220;portal&#8221;<br \/>\nmap.connect &#8216;:controller\/:context\/:div\/:action\/:id.:format&#8217;<br \/>\nmap.connect &#8216;:controller\/:context\/:div\/:action\/:id&#8217;<br \/>\nmap.connect &#8216;:controller\/:context\/:div\/:action&#8217;<br \/>\nmap.connect &#8216;:controller\/:action\/:id&#8217;<br \/>\nmap.connect &#8216;:controller\/:action&#8217;<br \/>\nRails adds the context to the URL when the portal generates the link URL and when the application makes a url using the url_for helper &#8211; the context (and div) are pre-pended to every URL &#8211; with zero changes to the application.<br \/>\nthe urls look like<br \/>\n\/controller\/site-id\/div-name\/action<br \/>\nBoth the URL made by the portal and the url made by views in the tool.<br \/>\nAbstraction abstraction abstraction &#8211; lots of flexibiltiy &#8211; lots of power.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I am amazed at the flexibility of Rails. I needed a way to dispatch between the portal and a tool and communicate which &#8220;context&#8221; \/ &#8220;site&#8221; the tool is supposed to operate in. In Sakai we have complex stuff like a request filter and obtuse code buried in portal to accomplish this. In Ruby it [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-379","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/379","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/comments?post=379"}],"version-history":[{"count":1,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/379\/revisions"}],"predecessor-version":[{"id":2468,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/posts\/379\/revisions\/2468"}],"wp:attachment":[{"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/media?parent=379"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/categories?post=379"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.dr-chuck.com\/csev-blog\/wp-json\/wp\/v2\/tags?post=379"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}