Solving [DEPRECATION] last_comment is deprecated when upgrading to rails 4.2.6

We ran into the deprecation warning above when we upgraded to Rails 4.2.6.

The issue was an older version of rspec-rails 3.3.3 and upgrading to 3.4.2 removed the warning.

To resolve all dependencies we edited our Gemfile to:

gem 'rspec-rails' , '3.4.2'
gem "rspec-activemodel-mocks" #, "~> 1.0.1"
gem "rspec-mocks", "~> 3.4.0"

then ran:
bundle update rspec-rails rspec-mocks accept_values_for

Getting S3Object.exists? to work correctly with IAM policies

When we updated our Rails 3.2 apps to each use their own IAM users and policies (instead of sharing a root S3 key/secret), we found that the aws-s3 (0.6.3) gem was causing S3Object.exists?() to always return true.

Although an updated aws-s3 gem may eventually fix the issue, the quick wrokaround was to modify the IAM policy to include both BUCKET and BUCKET/* (normally we need just the latter). Specifically:

{ "Version": "2012-10-17", 
"Statement": [ 
   { "Sid": "Stmt1234567890", 
    "Effect": "Allow", 
    "Action": [ "s3:*" ], 
         [ "arn:aws:s3:::SOMEBUCKET", 
          "arn:aws:s3:::SOMEBUCKET/*" ] 
}  ] }

My favorite Ruby thing this week: when *my_array

This week we added a feature where our texting club customers can define their own aliases for the JOIN keyword, so they can track and measure which advertising is attracting people to JOIN. (For example a receipt might say “Text JOIN to…” while a sign in a bus might say “Text SNOWBUNNY to ….”)

In Ruby, the basic use of case / when is something like:

case keyword
when "KEYWORD1"
  # do something
when "KEYWORD2"
  # do something else

In this case, the when needs to evaluate run-time data, not compile-time data. In Ruby it is trivially simply to implement run-time comparison arguments for a case – when statement by using an array name as the argument to the when clause.

The solution with Ruby is trivially simple: use when *array_name

join_aliases = ("JOIN " + myaccount.join_aliases.to_s).split(" ")
  # sets join_aliases = ["JOIN", "SNOWBUNNY", "SNOW"]
case keyword
when *join_aliases
  # do JOIN stuff