HEROKU: QUICK GUIDE TO DEPLOYING YOUR RAILS APP

 

Once you're up with the prerequisites: http://docs.heroku.com/quickstart

 

If you have some specific gem dependencies create a new file called .gems in the root directory of your app e.g.

 

mislav-will_paginate --version '>= 2.3.11' --source gems.github.com

authlogic --version '>= 2.1.2' --source gems.github.com

 

then:

cd myapp

git init

git add .

git commit -m "commit to git"

heroku create

git push heroku master

heroku db:push

 

(if you don't get a running app after the db:push then you may have a schema discrepancy - like when I did by naughtily deleting columns within mysql itself)

 

 

REFS:

http://docs.heroku.com/git

 

http://docs.heroku.com/gems

 

Filed under  //  heroku   rails  
Posted

Taming Rails Conditionals for Noobs: Or with Case

Sometimes you gotta wrestle some view into shape and the database might be part of the problem. Anyway, you end up in googleville or rails forums and don your hunting hat.

I needed to check for nulls, nils and plain old blanks to format my output nicely so I thought I'd end up with something like this:

 

<% case @person.address_2 when !nil, !'' %><%=h @person.address_2 %>,<% end %>

which doesn't throw an error, but it also doesn't really output properly, what does is:

<% if !@person.address_2.blank? %><%=h @person.address_2 %>,<% end %>

 

This tasty snippet allowed me to check for not *empty* before outputting an address section with a lovely comma (I didn't want a nasty looking string of commas when I didn't have an address).

 

As ever, they'll be a best practice ruby way but this worked for me, for now.

Filed under  //  rails   ruby  
Posted