How to Install Ferret, the Full Text Search Engine with Your Rails Application
Ferret is a full text search engine based on the popular Lucene Engine, which is originally written for Java. There is a great tutorial available here: http://www.railsenvy.com/2007/2/19/acts-as-ferret-tutorial
Assuming you have the plugin installed, act...
Written by Sean Behan on 06/17/2012
Starting the Rails Console in Production Mode
To specify which mode you'd like the rails console to boot up in, just provide the string without any flags.
./script/console production
./script/console test
./script/console development
If you're on windows, remember the backslash "\" rather than for...
Written by Sean Behan on 06/17/2012
Sample Rails Database Config for MySQL
Sample Ruby on Rails database config file for connecting to mysql.
production:
adapter: mysql
encoding: utf8
reconnect: false
database: db_production
pool: 5
username: db_user
password: db_password
#socket: /tmp/mysql.sock #this may vary
...
Written by Sean Behan on 06/17/2012
Rails Prototype JS and TinyMCE Autosave
TinyMCE is a nice little WYSIWYG for text processing online. It uses iFrames and Javascript callbacks to manipulate textarea form fields. Using it with Rails can be somewhat problematic if you want to set up an observer on a field that TinyMCE is managing...
Written by Sean Behan on 06/17/2012
Using jQuery and Prototype Javascript Together with jQuery.noConflict();
To use the jQuery javascript framework in a Rails application, that also uses the Prototype framework for the same application, you'll need to reassign the $() function for jQuery to another variable. This is very simple to do. Just make sure to include t...
Written by Sean Behan on 06/17/2012
Set Cron Job to Run Every Five Minutes for a Ruby on Rails Rake Task
First off you'll need to edit your cron file. Normally, the cron files are kept under /etc/cron.daily or /etc/cron.hourly but we can just use the command line tool, crontab and pass it the -e flag, so that we can edit the file without any fuss.
sudo cron...
Written by Sean Behan on 06/17/2012
Validate Uniqueness on Join Tables in Rails
How to validate uniqueness in a :has_many :through relationship with Ruby on Rails. You'll need three models in this example List, Subscriber and ListSubscriber. A list has many subscribers and a subscriber has many lists. Simple enough. Running the follo...
Written by Sean Behan on 06/17/2012
YouTube Internal Server Error
Thought I'd share a snapshot of this error message from youtube.com. It's nice to know that their monkeys are highly trained. I figured they just got those lazy monkeys who work for bananas.
500 Internal Server Error
Sorry, something went wrong.
A team o...
Written by Sean Behan on 06/17/2012
named_scope in Rails
Take advantage of the named_scope method in your models and make find queries simple and beautiful!
#app/models/comment.rb
class Comment < ActiveRecord::Base
belongs_to :post
named_scope :pending, :conditions => ["pending = ?", true]
named_scope :...
Written by Sean Behan on 06/17/2012
When the cloud is a good idea
A buddy of mine is a talented, but paranoid System Administrator for a small web company. He refuses to see the truth and the beauty in the wonderful world made possible by cloud computing services like Amazon's EC2. Amazon is not the only game in town. T...
Written by Sean Behan on 06/17/2012