Rails 4, phantom ArgumentError: wrong number of arguments (0 for 1) on UserSession.find for AuthLogic

This was a total pain to locate, as the exceptions being raised were pointed to UserSession.find in Authlogic::Session::Persistence.

gems in question:

  activerecord-session_store 0.1.1
  authlogic 3.4.6
  activerecord 4.2.3
  rails 4.2.3

I noticed that the only meaningful difference between the two environments was the following instance variable in Rails.application.config:

irb> pp Rails.application.config

Commenting out this initialization in the environment allowed the application to work again.

   config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new('name of log'))

Searching on “usersession syslog rails 4” results in the following issue as the third search result: Version 0.1.1 breaks Syslog::Logger setups There is a fix in master, but it doesn’t seem to have been published. I had promoted activerecord-session_store to 0.1.1 because DEPRECATION WARNING: `#quietly` is deprecated in rails-4.2.0.beta4, but it looks like locking the gem at 0.1 will work otherwise except for noisy tests.


Pundit: NoMethodError (undefined method `verify_authorized’ for [WhateversController])

Sometimes, having done things several times before can make you miss the OBVIOUS.

After adding

  after_action :verify_authorized

to my ApplicationController to verify that Pundit was being used for authorization, I got the following error in rspec:

  2) Jobs GET /jobs works! (now write some real specs)
     Failure/Error: get jobs_path
       undefined method `verify_authorized' for #
     # ./spec/requests/jobs_spec.rb:6:in `block (3 levels) in '

Maybe there’s a problem with my RSpec? Nope:

Started GET "/" for at 2015-07-31 07:13:17 -0500
Processing by JobsController#index as HTML
  Job Load (0.1ms)  SELECT "jobs".* FROM "jobs"
  Rendered jobs/index.html.slim within layouts/application (0.5ms)
Completed 500 Internal Server Error in 8ms

NoMethodError (undefined method `verify_authorized' for #):

Okay, does ApplicationController have the method?!

irb(main):008:0> ApplicationController.new.methods.include? :verify_authorized
=> false

Ok, am I doing that wrong?

irb(main):010:0> ApplicationController.new.methods.include? :authenticate_user!
=> true

Sigh. *Rereads documentation.*

Screenshot 2015-07-31 07.25.24

What’s missing? Oh yeah, a simple `include Pundit’ in the ApplicationController

Bootstrap 3 radio-inline and checkbox-inline elements running together.

I was having issues with Bootstrap 3 radio buttons running together even though the labels had a “radio-inline” attribute.

After examining the layout of the html being generated, I realized that each individual label and radio button was being wrapped in its own containing element (in this case, a “td” element.)

The reason for this is the following CSS:

.radio-inline + .radio-inline, .checkbox-inline + .checkbox-inline {
  margin-top: 0;
  margin-left: 10px;

If the .radio-inline elements aren’t adjacent to each other, the ‘margin-left’ value will not trigger.

Unfortunately, it took a little too long to track down the source of the issue, but now I know.

The “Satirical News” Sites Need to Stop

The Onion has always been entertaining because it either operated at a very generic level or a very absurd level. While The Onion could be mistaken for real news, it was often involving a person that didn’t exist, a generic group of people, or things so absurd that no reasonable person could believe them to be real. Besides, The Onion was THE ONION.

However, now there’s a proliferation of “satirical news sites”.

The latest in the absurdity is Newslo, which is:

JUST ENOUGH NEWS… Newslo is the first hybrid News/Satire platform on the web. Readers come to us for a unique brand of entertainment and information that is enhanced by features like our fact-button, which allows readers to find what is fact and what is satire.

I’m trying out “SatiricAlert” to help me filter out this crap that has proliferated way too much to be entertaining anymore.

Hooking in an LDAP Test Server to Cucumber Tests

I managed to get a custom Devise strategy with LDAP working, but had no clear way of automating tests. I wanted to validate if I still had to keep the password fresh in the database, and needed to be able to write scenarios around that in case someone attempted to refactor out the code.

After trying to incorporate the spec strategy used in the development devise_ldap_authenticatable and failing, I found a ruby wrapper of ApacheDS called ladle that looked like it would serve my purposes.

I included in gem in my test group in my Gemfile:

  gem 'ladle'

At the top of my features/env.rb file for configuring cucumber, I turned off admin binding (wanted the connection as simple as possible):

::Devise.ldap_use_admin_to_bind = false

I then created an @ldap tag for my LDAP-dependent features than would start and stop the LDAP server in those instances. (Again, in my features/env.rb… probably need to clean that up.)

Around('@ldap') do |scenario, block|
  $ladle ||= Ladle::Server.new(
    :ldif => "spec/ldap/test_users.ldif",
    :domain => "dc=example,dc=org",
    :quiet => true

I then created an the spec/ldap/test_users.ldif (from following the example in the ladle project).

version: 1
dn: ou=people,dc=example,dc=org
objectClass: top
objectClass: organizationalUnit
ou: people
dn: uid=eadmin,ou=people,dc=example,dc=org
objectClass: top
objectClass: person
objectClass: organizationalPerson
objectClass: inetOrgPerson
cn: Example Admin
sn: Admin
givenName: Example
mail: eadmin@example.com
uid: eadmin
# Password is "b44b44bl@cksh33p!"
userpassword: {SHA}Aedq5WHQSxglvJSfpX0kgdGRdHk=

I generated the password with:

  slappasswd -h {SHA} -s b44b44bl@cksh33p!

One stupid mistake that I did in the process was kicking off two Ladle servers (with slightly different parameters). In one iteration, I couldn’t bind to the user. Another, the server using the test file failed to start. Be aware that Ladle will run happily with default parameters, but that they won’t be much use to you.

If you want to test your configuration file:

require 'net/ldap'
require 'ladle'
$ladle ||= Ladle::Server.new(
  :ldif => "spec/ldap/test_users.ldif",
  :domain => "dc=example,dc=org",
  :quiet => true
ldap = Net::LDAP.new(host: 'localhost',
    :port => 3897,
filter = Net::LDAP::Filter.eq('mail', 'eadmin@example.com') # or ('uid', 'eadmin') 
ldap.search(:base => 'ou=people,dc=example,dc=org', :filter => filter) do |entry|
  ldap.auth(entry.dn, 'b44b44bl@cksh33p!') # or whatever your password is
  entry.each do |attribute, values|
    puts "   #{attribute}:"
    values.each do |value|
      puts "      --->#{value}"

Kentucky Lottery Pick 3 Expected Payout Weirdness

The expected payouts for the Kentucky Lottery Pick 3 game have an interesting idiosyncrasy. Playing the special “Straight Box” play pays out better than a separate 50¢ straight and 50¢ box play.

All other plays average 60¢ per dollar played, but the straight box seems to be 65¢ and 70¢, depending on the numbers played. Maybe my spreadsheet is wrong somewhere in here:

Kentucky Lottery Pick 3 Payouts and Odds

devise_ldap_authentication for your domain email on top of database_authenticatable

I have a devise user model named LoginUser whose authentication key is :login. I want normal users of the system to be database_authenticatable.

However, I want to be able to authenticate previously added users via internal LDAP. Furthermore, I didn’t want the underlying database_authenticatable password to be used or to expire on me (also using devise_security_extensions). Most of the work is in the LocalOverride custom strategy’s authenticate! method, with a few other hooks (such as default strategy added to devise.yml).


To allow all other strategies to be used, but still trap our domains for one-off LDAP auth, I added devise :ldap_authenticatable to a singleton class inherited from the user loaded by the custom strategy.

Also, removed the other two “fails” from the code. Not necessary and will result in a “Failed to Login” message for too many other Devise-related Unauthorized events.

In config/initializers/local_override.rb:

module Devise
  module Strategies
    class LocalOverride < Authenticatable
      def valid?
      def authenticate!
        if params[:login_user]
          user = LoginUser.find_by_login(params[:login_user][:login])
          # trap our domain only
          if params[:login_user][:login] =~ /@example.com/
            # fail! halts the authentication chain completely
            return fail! unless ::Devise::LDAP::Adapter.valid_login?(params[:login_user][:login])
            class << user
              # make use of ldap_authenticatable for custom strategy only
              devise :ldap_authenticatable
            return fail! unless user.valid_ldap_authentication?(params[:login_user][:password])
            # use the after_ldap_authentication hook
            return success!(user)
Warden::Strategies.add(:local_override, Devise::Strategies::LocalOverride)

In config/initializers/devise.rb:

  # use local_override as default strategy
  config.warden do |manager|
    manager.default_strategies(:scope => :login_user).unshift :local_override

In config/models/login_user.rb:

class LoginUser < ActiveRecord::Base
  devise :database_authenticatable,
         :recoverable, :trackable, :secure_validatable,
         :authentication_keys => [:login]
  def after_ldap_authentication
    # force fresh password every log in
    self.password = self.password_confirmation = Random.new.bytes(47)
defaults:  &defaults
  host: our.ldap
  port: 636
  attribute: mail
  base: dc=IDENT,o=Orgname
  admin_password: adminpassw0rd
  ssl: sslmethod

See local_override.rb for original tip that got me there.


One Year In: Prius 2014 Gas Mileage + Thule Carrier + Road Trip

Prius with Thule Cargo Box

The Prius has definitely been a very geeky car to play around with and figure out. It’s been fun to see how various environments and driving styles impact it.

My initial driving in the summer of last year yielded about 42.9 MPG. This was in stop-and-go traffic, but often stopped long enough that the engine would have to kick in to power the A/C while idle. I was able to optimize to about 45 MPG with 72ºF+ auto A/C and on a route that allowed for more constant movement.

The first road trip (1 adult, 2 kids) down I-65 to Florida in the summer yielded tanks MPG of 39-42 MPG. Another road trip to South Carolina with two adults and two kids yielded 39.6 MPG for the trip.

The brutal winter earlier this year was pretty frustrating on gas mileage. The only driving done in the car was done with the engine running constantly just to try and warm up, and I discovered that there’s no good way to get a Prius warm enough to melt the ice on your windshield unless you edge it into the sunlight. There were a few tanks that I got 33 MPG on.

We eventually installed Thule Aeroblades on our car which allowed mounting of a Thule Cargo Box. The car got under 40 MPG with the cargo box mounted, but did about 35.8 MPG on the highway drive down. The best tank MPG that I got on our Camry on 100% interstate was still under 35 MPG.

Of course, the biggest gas mileage benefit of the Prius was when we were driving 4-8 miles back and forth on St. George Island at 25-35 MPH. I’d occasionally make trips without the engine even turning on, and the average trip MPG was over 50 MPG.

Almost a year in, this car has been fun to play around with and a great road trip car (especially with the roof rack). The biggest surprise is how it has fascinated my geek side.

No Bikes, No Ice Cream, No Bacon, No Ice, No Signal, No Laundry – St George Island Spring Break

2015-04-08 13.26.00
View from the bay side of SGI.

Based on the fact that people seem to love to go to St. George Island, Florida with their dogs, and the $24/night camping available at Dr. Julian G. Bruce St. George Island State Park, trying a new place for Spring Break seemed to be worth the risk. Unfortunately, our risk calculation was poorly researched from the start. Our normal beach destination, Santa Rosa Beach, FL, is only a 9 1/2 hour drive from Louisville, KY vs. over 11 hours to SGI. Fortunately, we broke up the drive both ways with overnight stops, but that seemed to just add to the perceived travel time.

I’d imagine part of the appeal of SGI is its relative remoteness. The state park is on the eastern tip of the island as well, which makes it even more remote. The campsites are 4 miles from the entrance to the park (with official speed limits of 15-25 MPH). It’s another 2-3 miles at 35 MPH from the state park to the first commercial businesses. Camping with limited food supplies meant that eating often required a 30+ minute round trip. The state park didn’t have laundry facilities as our normal Spring Break destination state park does, and the closest laundromat is back across the bridge (probably 20+ minutes away).

Somehow, the squirrels and raccoons on a island that is only connected to the mainland by a 6 mile long bridge are more numerous and aggressive than the animals in the park at Santa Rosa Beach, Florida, just 2-3 hours west on US-98… it only required a few minutes of someone carelessly leaving a campsite unattended for food to be devoured by squirrels in the day and raccoons at night. Of course, it’s not that surprising for experienced campers that animals will target your food, but the efficiency and skill at which they did it *was* surprising. One such casualty was a pound of bacon left in a cooler. The mosquitoes were also out in way more force than other camping trips to the panhandle.

The business owners on SGI expressed surprise that last week was the busiest week they’ve ever experienced. We weren’t able to try to rent bikes until Monday morning, and by then, there were no adult bikes available on the island. We ended up with with 2 20″ bikes and a beat up adult tricycle with a basket for $125. Not really that bad a deal, but one of the bikes went unused most of the week because of its size.


Restaurants seemed to be a bit pricey relative to our regular stops of Edisto, Santa Rosa, and Outer Banks. Taxes are 7% SGI tax + 2% local option, which further inflates your bills.

Truly Disconnected and the Restaurants

Wireless signal was non-existent for us. Looking at coverage maps, it appears that the magic carrier down on St. George Island is Verizon.

Harry A’s and Subway were staples of the week. Harry A’s is moderately priced, but they have solid wifi, which was necessary because our T-Mobile phones were rarely capable of even texting. Subway actually advertises “We have wifi”. Obviously, it’s a pervasive problem.

The Blue Parrot Paradise Cafe was good and is on the Gulf side which was good for the view, but horrible for cell phone reception and they don’t have wi-fi.

Eddie Teach’s was a pretty miserable experience on a Wednesday night. They ended up being crowded, and then we made the mistake of ordering a pizza for my daughter. The pizza clearly comes from elsewhere–pretty sure it was from the gas station in Eastpoint, 6 miles away. When the pizza came back, the order was wrong, so they reordered. We had a dispute with the owner about whether we should be paying for a pizza that was 30 minutes later than the rest of the order, etc. I won’t be going back there again if I end up on SGI, and I’m definitely not ordering the pizza. My wife got an order of nachos for $10.99 that was pretty mediocre, too.

It seems that the businesses run into supply issues due their remoteness. Subway ran out of bacon. The ice cream shop next to the beach store had a few pathetic looking tubs of partially melted ice cream where there should have been 30 selections or so. The state park ran out of ice for sale on our second to last day (Thursday) with no apparent expectation of it being replenished. Edisto Island in South Carolina seems similarly isolated, but doesn’t seem to have the same supply problem… yet.

Two pleasant surprises of our trip

  • The Apalachicola Bay Aquatic Preserve has several small aquariums showcasing area aquatic life and other exhibits. It’s either brand new or kept in pristine condition.
  • Our trip to Apalachicola, which gave me the opportunity to stop in at the Oyster City Brewing Company (no food, just tap room) and then have incredibly inexpensive dinner at The Hole in the Wall. I would definitely spend more time in Apalachicola next time… it has so much old city charm. Unfortunately, many places seem to close early there.

Trails and Activities

I didn’t bother with my own bike (considering there weren’t any available), but if I had, I would have ridden down the multi-use path that goes down the main road across the island. It goes on for miles (13+ if I recall correctly), but it wasn’t scenic enough for my interests, and it was too far away (4 miles) to run to. Instead, I first explored the limited access park road beyond the last beach access. It’s mostly sand and gravel, and wasn’t suitable for either trail or standard running shoes. More importantly, it had no shade to speak of, so I ran 3 of the 4.2 miles out, and ended up overheating from the sun and walking back.

I next tried the path to the primitive campsite (and Gap Point). 2.5 miles (one way) of about 50% dunes with slightly more shade than the other paths. It was more interesting, but there wasn’t the usual mental stimulation of a trail run, as there’s pretty much only one direction to go in. On my way back, I tried the East Slough trail that goes over wooden bridges. I was pressed for time and baking in the sun so I cut that exploration short.

Final Thoughts

Maybe it was more humid than normal this year. Maybe SGI was more crowded this year.

Experiences with Dropbox as iPhoto Library Backup


The renewal on my annual Mozy Backup subscription was due, and I decided that I wanted to consolidate backup solutions. Dropbox had (recently?) upped their Pro plan to 1TB, so there was plenty of room to back up a 100GB iPhoto library.

I made the switch on Wednesday of this week, dragging the iPhoto library in Photos over to the Dropbox folder (do this with iPhoto closed and then double-click once moved to let iPhoto figure out the new location.) I did a selective sync to another computer that was lacking in hard drive space so that the Dropbox sync wouldn’t eat up all the space.

Finder claims there are about 98,000 in the library. Dropbox was indexing about 360,000. I haven’t dug into the discrepancy, but I’m guessing hidden files aren’t in the Finder count. 


MacBook Pro mid-2009 model, 8 GB RAM, 1 TB 5400 RPM HD, 50/10 Mbps Cable Internet service through TWC. 


Default setting for Dropbox upload is to “Limit automatically” (as shown below) to minimize disruption to other Internet activities. I had to change that to “Don’t Limit”.

Dropbox Network Settings

As of Saturday (3 days later):

I’ve also done a disk clone of the of the 1TB and gotten caught up on Time Machine backups, but three days later, Dropbox has indexed half of the files and uploaded 10GB of data. 

 As of Monday (5 days later):

Dropbox is down to only indexing its last 18,000 files (5.6%) and has uploaded roughly 85 GB of data.

As of Wednesday (7 days later): Dropbox appears to have backed up 160 GB of data, but it also appears to have crashed at some point along the way as well.