Ruby on Rails - My Micromount database revisited

July 22, 2017

It has been perhaps a year since I had occasion to run this rails application, and as usual it is blowing chunks when I try to do things with it.

Just for the heck of it, I stop the server and type "bundle update", which indeed installs a whole bunch of stuff. But I still have problems.

Missing pstoimg

This is by no means a rails issue. This is provided by the fedora package "latex2html" and was not reinstalled after a major system update, so do "dnf install latex2html" and it will be possible to get label previews.

Circular warning from time_zone.rb

This is the first of two rails errors. When I start the server (using "rails server"), I get a warning I have never seen before:

.gem/ruby/gems/activesupport-4.1.0/lib/active_support/values/time_zone.rb:285: warning: circular argument reference - now
One good thing about dragging my feet like I do, is that I can do google searches for magical commands to fix my problems. The advice on this one is to either upgrade to something like Rails 4.1.9 or to issue the mysterious command "bundle update ruby-ole". I try the ruby-ole thing, but it simply tells me that it could not find such a gem.

So I edit the Gemfile and change the rails version from 4.1 to 4.1.9 and issue "bundle update". Success! I can now start the rails server without the circular argument warning.

apply_finder_options method is missing

This persists even after fixing the above and upgrading to Rails 4.1.9

When I do a database search, I get an error screen with the message:

Action Controller exception
NoMethodError in MountsController#search
undefined method `apply_finder_options' for #
This is being triggered by a line (which used to work fine, mind you) like this:
@mounts = Mount.paginate( :page => params[:page], :per_page => @@mpp, :order => 'location', :conditions => [ 'species LIKE ?', target ] )
The story is that the "apply_finder_options" method was moved out of active_record into a new gem called 'activerecord-deprecated_finders'. So I could add this gem to my Gemfile, but as long as we are tackling this, I would rather fix the code to not use deprecated gems and methods. This is really a problem with will_paginate (since it is using the deprecated method), but the way to do this is to restructure my code so that active_record handles the order and conditions clauses itself, and we just use will paginate to paginate.

Changing the above to this does the trick:

@mounts = Mount.order('location').where( 'species LIKE ?', "%#{target}%").paginate( :page => params[:page], :per_page => @@mpp )

Feedback? Questions? Drop me a line!

Ruby on Rails notes / tom@mmto.org