April 25, 2014

ElasticSearch - Getting Facet Counts Correct

If you use a regular filter, your facet counts will still include the filtered records.  Instead of a filter, use a query filter with your query and your filter being children of the query filter.

April 24, 2014
April 18, 2014

Git save credentials

Because I’ve looked this up three times already:

git config --global credential.helper "cache --timeout=3600"
March 9, 2014

Bitnami Rubystack Virtual Host Configuration

I recently upgraded to a new version of Bitnami Rubystack, which upgraded Apache from 2.2 to 2.4.  Try as I may, I couldn’t get my virtual host to come up.  I finally traced this back to default virtual hosts being defined for in one of the bitnami configuration files.  So if you are fighting with this, comment out the reference to  Include “/opt/bitnami/apache2/conf/bitnami/bitnami.conf” at the bottom of the default httpd.conf file.

March 5, 2014

Rebuilding an Elasticsearch Index

So for the next time I forget this, here are the steps needed to rebuild and Elasticsearch Index using the Tire gem with ActiveRecord integration:

  • Klass.search_index.delete
  • Klass.create_elasticsearch_index
  • Klass.import

Where Klass is the name of the class you have defined the index on.

February 28, 2014

Installing ElasticSearch on Ubuntu

This worked great for me:

If you want elasticsearch to start on startup, be sure to follow the instructions that are given once the package is installed:

  • sudo update-rc.d elasticsearch defaults 95 10
  • sudo /etc/init.d/elasticsearch start
February 27, 2014

Rails 3.2 -> Rails 4.0 Upgrage

So some random notes around what I’ve run into.

First off, if you haven’t already, generate a new Rails 4 project, just so you have something to refer to/steal from.

Here are changes that I’ve had to make

Gemfile

  • Specify rails 4.0 - gem ‘rails’, ‘~> 4.0.0’
  • Get rid of assets block - I’ve been replacing it with the following:

gem ‘sass-rails’,   ‘~> 4.0.0’
gem ‘coffee-rails’, ‘~> 4.0.0’
gem ‘uglifier’, ‘>= 1.3.0’

Scripts

  • Rails 4 has moved the location of the rails script from /scripts to /bin.  I generated a blank Rails 4 project, and copied the /bin directory over.

application.rb

  • Remove the ‘require “active_resource/railtie” ’ line
  • Reduce the bundler block down to simply ‘Bundler.require(:default, Rails.env)’

environments

  • Get rid of config.whiny_nils
  • Set config.eager_load according to the warning you will get when you start the rails server

routes.rb

  • Change all your match calls to get/post calls

That pretty much did it for getting the application up and running for me.  Of course, after that, you have to start dealing all the other changed and depreciated features.  Be sure to be watching your development server log, as it does a good job at telling you what to dig into.

February 14, 2014

Rails 4 - Custom Fonts - One more Thing

Missed one step in my previous post.  It appears that when you precompile your assets, you need to specify your rails environment, or the results will be, shall we say, ‘inconsistent’.  Use the following command to precompile your assets:

 RAILS_ENV=production rake assets:precompile

Also, if you are getting flakiness, kill off the contents of the public/assets folder, forcing everything to recompile.

Rails 4 SCSS font-path Helper

I ran into a problem with a custom font that I was using, in that while the asset pipeline was adding the hash to the name of the font files, it was not adding it in the font-face definition in the generated CSS file, and thus I was getting 404 while trying to download the fonts into the browser, and no pretty icons on my page.  After a couple of hours of thrashing about, I finally found the solution.  As it turns out, I had the font-face definition in a file that I included into another file.  Moving the font-face definition into the master scss file fixed the problem.  It appears that there is some issue with font-path not generating the correct url from an includes.

Rails 4 Asset Pipeline

Ran into a problem deploying my application to production - not all my CSS files were getting compiled when I did a assets:precompile.  I use a couple of page type specific manifest files.  I had added these into my config.assets.precompile in the production.rb, but it was being ignored.  After finding this issue: https://github.com/rails/sprockets-rails/pull/36, I moved the config.assets.precompile to the application.rb, and life got better.