Keeping up with the train – Lots of work for little features

Ruby on Rails 2 has been out for a good month or two by now. And my hosting provider, Dreamhost, added the gems to support 2.0.2 just after New Years Eve, So obviously I had to upgrade the Laurelin Community Site.

I had been on it already before christmas. But motivation was lacking and it turned out it required some modifications to get going. Specifically the wise guys of Rails Core decided nobody was using pagination so it had to go. Or possibly they decided they where unable to improve it and hoped the community would fill the gap with something better? So the old pagination stuff was kicked out of Rails 2 and replaced with an optional (and likely very unsupported) plugin while telling everyone to use something else.

So I turned to will_pagination as it seemed like it was the most recommended one of the young Rails 2 scene. It appears to work well but I had to redo my pagination control. So far I have just hacked something ugly together… seems to work with the ugly site anyway.

The biggest hurdle then was that my auth_generator-based user-login system seems to have been unsupported for ages. And it had several issues with Rails 2. And that my use of pagination with the acts_as_taggable_on_steroids plugin had to be changed. Both was fairly simply. The latter would have been tricky if I hadn’t found a trick in a comment on on a blog. The actual proposed fix in the main blog entry being way too much work for me to bother with 😉

On the up-side it seems that Rails 2 run a bit faster than Rails 1 did. Maybe it’s just placebo tho. I guess I’ll have to see about that.

Then I fixed a slight bug on the site (if someone used ‘ in a name that was to show up in the Housing Directory. It would no longer show markers on the map when page loaded). And added Kinship profile links that use the kinship name instead of their id. And off to release it went. So it is now live on Rails 2.

Post release I did get one major annoyance. Mainly that if I use the same cookie name as the Rails 1 site I’d have people throwing exceptions when they first returned to the site. Changing the cookie name should have fixed that. I hope 😉

No Trackback/Pingback

You can trackback from your own site.

  • Sebastian

    Hey, after upgrading to Rails 2.1 i think i go into the same trouble like you regarding the auth_generator. Can you post or email me some hints or a patch about wha you have changed to get i working again?

    All the best,
    Sebastian

  • Looking back in my Subversion it seems that it was mostly fixing reference to code that is no longer in Rails. Specifically I changed auth_helper.rb like so:

    Index: auth_helper.rb
    ===================================================================
    --- auth_helper.rb	(revision 647)
    +++ auth_helper.rb	(revision 863)
    @@ -1,11 +1,11 @@
     module AuthHelper
    -
    +  
       # For theme support. Idea from Typo.
       def search_paths(path)
         ["#{path}/theme/#{this_auth[:theme]}/",
         ]
       end
    -
    +  
       def full_template_path(template_path, extension)
         template_path_dirs = template_path.split('/')
         dir = template_path_dirs[0]
    @@ -17,7 +17,7 @@
         end
         super
       end
    -
    +  
       # Taken from the webrick server
       module Utils
         if !const_defined? "RAND_CHARS"
    @@ -32,60 +32,64 @@
           ret
         end
         module_function :random_string
    -
    +    
         # define a regexp for valid IPv4 host
         def valid_ipv4_host_regex
           zero_to_254 = "([0-9][0-9]?|1[0-9]{2}|2[0-4][0-9]|25[0-4])"
           one_to_254  = "([1-9][0-9]?|1[0-9]{2}|2[0-4][0-9]|25[0-4])"
    -
    +      
           /A#{one_to_254}.#{zero_to_254}.#{zero_to_254}.#{one_to_254}z/
         end
         module_function :valid_ipv4_host_regex
    -
    +    
       end
    -
    +  
       # Show user informations using Ajax. Can be used on static pages / cached pages.
       def ajax_account_infos()
         "" + javascript_tag('function showloginform() {'+ 
    -        remote_function(:update => "accountinfo", :url => { :controller => "auth", :action => "remotelogin" }) +
    -        ' document.getElementById('post_login').focus();}') + "<!-- account info --> <div id="accountinfo">"+
    -        link_to(auth_icon('buddy'), auth_url) + "</div>" +
    -        javascript_tag("new Ajax.Updater('accountinfo', '/auth/remoteinfo', {asynchronous:true});")
    +    remote_function(:update => "accountinfo", 
    +    :url => { :controller => "auth", :action => "remotelogin" }, 
    +    :success => "document.getElementById('post_login').focus();") + "}") + "<!-- account info --> <div id="accountinfo">"+
    +    link_to(auth_icon('buddy'), auth_url) + "</div>" +
    +    javascript_tag("new Ajax.Updater('accountinfo', '/auth/remoteinfo', {asynchronous:true});")
       end
    -
    +  
       # Show user information, don't use for static or cached page!
       def account_infos()
         "" + javascript_tag('function showloginform() {'+ 
    -        remote_function(:update => "accountinfo", :url => { :controller => "auth", :action => "remotelogin" }) +
    -    ' document.getElementById('post_login').focus();}') + "<!-- account info --> <div id="accountinfo">"+
    +    remote_function(:update => "accountinfo", 
    +    :url => { :controller => "auth", :action => "remotelogin" }, 
    +    :success => "document.getElementById('post_login').focus();") + "}") +
    +     "<!-- account info --> <div id="accountinfo">"+
         render(:partial => "auth/remoteinfo") + "</div>"
       end
    -
    +  
       # Javascript version to show user information. Can be used on static pages / cached pages.
       def js_account_infos()
         "" + javascript_tag('function showloginform() {'+ 
    -        remote_function(:update => "accountinfo", :url => { :controller => "auth", :action => "remotelogin" }) +
    -    ' document.getElementById('post_login').focus();}') + "<!-- account info --> <div id="accountinfo">" +
    +    remote_function(:update => "accountinfo", 
    +    :url => { :controller => "auth", :action => "remotelogin" }, 
    +    :success => "document.getElementById('post_login').focus();") + "}") + "<!-- account info --> <div id="accountinfo">" +
         "<script src="/auth/jsinfo" type="text/javascript"></script>"+
         '<script type="text/javascript">displayAccountInfo();</script>' + "</div>"
       end
    -
    +  
       # store current uri in the ccokies
       # we can return to this location by calling return_location
       def store_location
         cookies[:return_to] = {:value => request.request_uri, :expires => nil }
       end
    -
    +  
       # Loading spinner indicator icon tag
       def spinner_tag(id = 'ident')
         image_tag('auth/spinner.gif', :id=>"#{id}_spinner", :align => 'absmiddle', :border=> 0, :style=> 'display: none;', :alt => 'loading...' )
       end
    -
    +  
       # auth_generator's images tags
       def auth_icon(name)
         image_tag("auth/#{name}.png", :align => 'absmiddle', :border => 0, :alt => name)
       end
    -
    +  
       # image tag for user
       def user_icon(user)
         if @app[:gravatar] == true
    @@ -99,9 +103,9 @@
           auth_icon('buddy')
         end
       end
    -
    +  
       def user_logged_in?
         not @user.nil? and @user.ident == true
       end
    -
    +  
     end
    </div></div>

    Also I fixed a small deprecation in auth_helper.rb by replacing redirect_to_url with redirect_to