Writing
Notes on building software — the decisions that age well, the ones that don't, and what I learn in between.
-
Rails Migrations and Auto Incrementing Migration Prefix Number
In your environment.rb file turn off timestamped migrations like so:
-
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:...
-
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. If you're on windows, remember the backslash "\" rather than forward "/" and I believe...
-
Sample Rails Database Config for MySQL
Sample Ruby on Rails database config file for connecting to mysql.
-
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...
-
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...
-
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,...
-
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...
-
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...
-
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...
-
named_scope in Rails
Take advantage of the named\scope method in your models and make find queries simple and beautiful! Now you can get all comments for your posts that are marked as pending with this method:
-
Wildcard VirtualHost with Apache2
Set your ServerAlias directive to \.domain.tld - Here is a quick example. Now everything.example.com and anything.example.com, even though you didn't explicitly set them, will map to the...
-
Ruby strftime() method arguments
Just for reference strftime() arguments in ruby. Usage Time.now.strftime("%B/%d/%Y") %a weekday name. %A weekday name (full). %b month name. %B month name (full). %c date and time (locale) %d day...
-
Namespacing in Rails
With namespace routes in Rails you can easily create a prefix for select resources. For instance, if you have an admin area or an account dashboard you can give logged in users access to methods...
-
Using Prototype to Access Form Data
Prototype has a powerful API for accessing and manipulating the Document Object Model, A.K.A the DOM. The following code will let you interact with a simple web form. Suppose we have a form that...