How to setup Jasmine Rails31 directory structure
Following are instructions on how to setup/configure jasmine for use with rails31. It’s mostly straight forward, just one gotcha with regards to how to tell jasmine where your source files are. 1. Add...
View ArticleHow to reference domain classes in rails
Working with active records in rails is nice because a lot of your domain is directly represented in your model classes. Sometimes however, you still need to create some domain classes that aren’t tied...
View ArticleRails TimeRange
Say you want to query your backend objects with a range of times. One way to do that is to define a TimeRange object which captures the time ranges you are interested in: TimeRange.rb class TimeRange...
View ArticleA simple ruby script for reading the contents of a file and generating some...
Here’s a handy ruby script that will read the contents of a file regions.txt AB Aberdeen AL St. Albans B Birmingham BA Bath and generating some output (in this case sql) based on the content: sqlgen.rb...
View ArticleHow to add a boolean column to a table in rails
As a reminder to myself, here are some notes on how to add a boolean column to a table in rails3. Step 1: Create migration rails generate migration add_public_to_listings admin:boolean Step 2: Write...
View ArticleHow to embed HTML within a rails flash response
It doesn’t look pretty, but if you really wanted to embed a link in your rails flash response you could do it like this: flash[:success] = "Foo. #{ActionController::Base.helpers.link_to "Create new...
View ArticleHow to setup Rails3 postgres on mac
Update A much better way to install Postgres locally is to use Postgres.app. Do this and use the following commands to create your local root user (with no password) and database instance. psql...
View ArticleHow do rails environments work?
Rails environments are wonderful. But they can be a bit confusing do to some inconsistency in terms of which environments are affected when you run certain rake tasks. After some digging I think I...
View ArticleTips for sending email via Rails
Some reminders for how to configure email via a rails application. Watch this: http://railscasts.com/episodes/274-remember-me-reset-password Add this: production.rb config.action_mailer.delivery_method...
View ArticleASP.NET MVC vs Rails Routes
One thing I have always wanted to compare are the default routes you get with Rails, with the default routes you get with ASP.NET MVC. Rails ASP.NET MVC4 GET /Permits Index GET /Permits/Create Create...
View ArticleHow to read files from dir and generate html output
When creating videos, I take snapshots of keynote, upload to website, and then manually handcraft the html to include in the show notes. It’s slow, tedious, and not a lot of fun. So today I created a...
View ArticleHow to upgrade to Rails4 with Heroku
Rails migrations are never easy. But the community does it’s best to help you out. Here are some tips that helped me migrate my app: Watch this video by Ryan Bates – Upgrading to Rails4 Check out these...
View ArticleHow to add a git remote to a heroku app
There are two concepts at play here when add a user friend name hooking git up to a heroku app. There is the remote (git) and the app (heroku). git remote Git remotes are just aliases for git...
View ArticleHow to pass parameters as part of the URL in Rails
While building my latest rails app I wanted to pass the id of a video episode to my subscription service. I wanted to build a URL that looked something like this:...
View ArticleHow to add error messages top of rails page
Sometimes when I create views/controllers and models by hand I forget how rails gets error messages to appear at the top of a page. Here is a reminder for myself for when I need to add these manually...
View ArticlePrepping models in Rails using form_for
Sometimes when building forms the rails way, you need to do some funky stuff to get your models prepped so they can be worked on in the controller. For example, here I want to create a new...
View ArticleHow to setup and amazon webservices and connect to from Rails
Some notes for future me the next time I need to do this again. Create amazon webservice account Goto management console...
View Articleheroku db:pull no longer working – workaround
I was disappointed when I discovered that the very handy heroku db:pull stop working for me after upgrading to Ruby 2.0 and Rails 4.0. I got it going again – by basically reverting back to Ruby 1.9.3...
View ArticleHow to install postgres rails
Download and install http://postgresapp.com/ This will automatically create a postgres user with the name of your machine (i.e. jrasmusson). Add the ‘pg’ gem to your project. gem ‘pg’ $ bundle install...
View ArticleHow to import heroku postgres locally from prod rails
Step 1: Setup Postgres locally and get working with your app. Heroku db:pull only works if you have postgres setup locally on your machine. Go here for some tips on how to do that. Step 2: Find out...
View Article