Musician, Ruby on Rails Entusiast, Composer, Programmer and Lover of Hot Sauce
Posted: April 19th, 2010 | Author: mindtonic | Filed under: Design Patterns, Rails Plugins, Ruby On Rails | Tags: observers, rails, state_machine | No Comments »
I have been using AASM as my default State Machine Rails plugin for quite some time. It has always worked great, but now there is a better, more thorough State Machine I recommend. state_machine 0.9 has just been released, and as you can read in this blog post, they are rapidly moving towards the finalization of the 1.0 version. http://www.pluginaweek.org/2010/04/19/state_machine-0-9-0-locked-and-loaded!
What lead me to discover this fantastic plugin was the need to be able to call ActiveRecord observers in relation to the State of an object. With AASM, I had to incorporate my lib class calls in a method that was referenced in a state definition. I didn’t like this because it required my Model to have too much knowledge of the outside world. I think it is a best practice to encapsulate this type of functionality into an observer, leaving the model to be happy in it’s own little world. state_machine accomplishes this by allowing the placement of observer calls using a DSL provided by the plugin.
Posted: July 30th, 2009 | Author: mindtonic | Filed under: Development, Rails Plugins, Ruby On Rails | Tags: css, javascript, rails | No Comments »
To speed up site loading, there are two great plugins for “compressing” your stylesheets and javascript.
The first is bundle-fu. This plugin does not actually compress the files, but rather combines all of the individual documents into one before shipping it out to the client browser.
$ script/plugin install git://github.com/timcharper/bundle-fu.git
And then you simply wrap your sheet and script calls in the bundle method:
<% bundle do %>
...
<%= javascript_include_tag "prototype" %>
<%= stylesheet_link_tag "basic.css" %>
<%= calendar_date_select_includes "red" %>
...
<% end %>
The Second plugin, which actually does compress all of your files, is sbecker’s asset_packager. This one is a lot more involved, so check out the github site for more information.
Posted: June 24th, 2009 | Author: mindtonic | Filed under: Rails Plugins | Tags: rails, ruby, shoulda, sphinx, ultrasphinx | 2 Comments »
I use the Shoulda testing framework for my Rails applications. After installing and beginning to use the Ultrasphinx plugin, I needed to figure out how to configure and run in a testing environment. This blog entry held the answer: Stephen Celis: Testing with Ultrasphinx
Posted: June 24th, 2009 | Author: mindtonic | Filed under: Rails Plugins | Tags: mysql, rails, ruby, sphinx, ultrasphinx | 1 Comment »
After installing all of the necessary elements for Spinx and Ultrasphinx, I began following the instructions from Snax Fauna to get the system up and running.
rake ultrasphinx:configure
worked fine, but I encountered the following error upon attempting to index my models:
rake ultrasphinx:index
...
dyld: Library not loaded: /usr/local/mysql/lib/mysql/libmysqlclient.15.dylib
Referenced from: /usr/local/bin/indexer
Reason: image not found
In my configuration for development, I use the MAMP MySql server. The rake configure command correctly pulled all of the connection information from database.yml, so that was not the problem.
I searched around and finally encountered this solution from Michael Hartl:
$ sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
It worked brilliantly. Thanks Michael.