Archive

Posts Tagged ‘Development’

Rails: how to change the header (title) for the validation message

March 31st, 2010

The request was simple – how do you change the header (or title) for a validation message.  Using nested resources, I ended up with a weird message:

3 errors prohibited this page[contact attributes] from being  saved

Not very user friendly.   So, I hit Google, blogs and IRC.  So, here the solution I discovered.

<%= error_messages_for ‘c’, :header_message => “Please correct the errors below:”%>

Since this was part of a fields_for block,  I had to add this to my controller method:

@c = @section.contact

Andrew Development , , , ,

Jumping into Ruby on Rails – Part 3

February 5th, 2010

Well, I’ve been working on learning Ruby on Rails for several months now.  The past couple of months, I’ve focused more on my studies and I’m finally feeling comfortable with it.

I thought it would be best to share what I think would be the best way to approach learning Ruby on Rails based on all of my experiences.  So, here are my suggestions

1. Learn Ruby on Rails on Linux or a Mac.

Why?  It’s just easier.  An example to this is getting the MySQL gem installed on Windows – after hours of trying to figure this out, I finally gave up and started to use Linux.  You will spend hours trying to get something to work under Windows and to me that is just wasted time.  And I tried all different kinds of approaches – Cygwin, Instant Rails, etc.

2. Learn Ruby

Here are some suggestion:

Programming Ruby 1.9: The Pragmatic Programmers’ Guide (Facets of Ruby)

Free (if you buy a book) class.

Also, most Ruby on Rails books will give you a sufficient overview to the Ruby language to get started.

3. Expect gaps of informaton

This was a *huge* problem for me.  I started working my way through the Agile Web Development with Rails book, that presents itself as a book  from a beginner to an expert.  Well, I discovered that the book *expects* you know the nuances of Rails.

I’ve looked at a good number of books and found this one to be a great one to start with:

Ruby on Rails Bible

Note:  While the book was published in 2008, it covers Rails 1.2 – which was current in 2005.  So the book is a *bit* dated.  However, it does present itself with knowledge about Rails that other books leave out.  Also, as a co-worker pointed out, the web site for the book is – uh, well – broken.

So, specifically, as most Railists know – RoR is convention over configuration – and what I find missing in most books is a good explanation of the conventions.

4. Watch some screen casts:

Free

Railcasts

TeachMeToCode.com ** check out the Flitter tutorial

Paid

PeepCode ** $149 a year – has tutorials on Ruby, Rails, and much more!

Well, that’s my advice.  Let me know if you have any suggestions!

Andrew Development , , ,

Rails Newb – how to install will_paginate

January 24th, 2010

One of the frustrating things about Rails is coming up to speed with everyone else.  A very simple task can be difficult, just because you haven’t done a particular task yet.  Well, that’s ok.  That’s what the community is for.  So, I’m sharing those little things here.

This one is how to install will_paginate.  Not so much how to install it – but how to add a new source to the gem sources.

gem sources

do you see http://gemcutter.org?  if so, skip the next command

gem sources -a http://gemcutter.org

sudo gem install will_paginate

Andrew Development , , , , , ,

Preparing a VPS for Ruby on Rails

October 5th, 2009

The instructions have been updated here.

Here are the steps I use to install Ruby on Rails on my VPS (www.rackspacecloud.com) a Ubuntu  9.04 (jaunty)

apt-get update
apt-get upgrade
apt-get install build-essential
aptitude install ruby1.8-dev ruby1.8 ri1.8 rdoc1.8 irb1.8 libreadline-ruby1.8 libruby1.8 libopenssl-ruby sqlite3 libsqlite3-ruby1.8
aptitude install ruby build-essential libopenssl-ruby ruby1.8-dev
apt-get install sqlite3 libsqlite3-ruby1.8
apt-get install rubygems
ln -s /usr/bin/gem1.8 /usr/local/bin/gem
ln -s /usr/bin/ruby1.8 /usr/local/bin/ruby
ln -s /usr/bin/rdoc1.8 /usr/local/bin/rdoc
ln -s /usr/bin/ri1.8 /usr/local/bin/ri
ln -s /usr/bin/irb1.8 /usr/local/bin/irb
export PATH=$PATH:/var/lib/gems/1.8/bin
gem install -v=2.3.4 rails
gem install rubygems-update
update_rubygems
gem install rails
gem install -v=2.3.4 rails
export PATH=$PATH:/var/lib/gems/1.8/bin

Andrew Development , , , , , , , , ,

Jumping into Ruby on Rails – Part 2

October 5th, 2009

iStock_000003167001XSmallSo, I’ve made the decision to write my apps in Ruby on Rails.  Now what?

Here are the books I chose to start:

Agile Web Development with Rails, Third Edition

Programming Ruby 1.9: The Pragmatic Programmers’ Guide (Facets of Ruby)


Additionally I found an online class at a reasonable rate:

Introduction to Ruby on Rails – I highly recommend the class.  It  gives you an opportunity to ask the “do I understand this correctly?” or “compared to C#, is this the same?” type of questions.


There are some other helpful resources:

Learning Rails – a great site with resources on learning Ruby.

PeepCode Screen Casts -tutorials on Ruby.

Ruby Mine – an IDE for Ruby.  (I’m downloading to try it out and will be writing a review on it later.)


My Lab in the Cloud

So, I’ve set aside a budget for all of this and one thing that I included was a VPS (virtual private server).  Now, I know what you’re thinking, isn’t this a bit overboard for learning RoR?  Perhaps, but I found a provider that offers cloud hosting for as little as $0.015 an hour.  Roughly, that’s about $10 a month.

My production VPS is hosted at another site, which I pay about $30 a month.  It hosts several blogs (including this one) and my email server.

Andrew Development , , , , ,

Jumping into Ruby on Rails – Part 1

October 3rd, 2009

iStock_000007473721XSmallFor the past 20 years, I’ve covered quite a bit of ground in technology – from help desk to management.  Through the various positions I’ve held, I’ve never been a programmer full-time.  However, in all of the positions I’ve held, I’ve always managed to do some programming to improve processes.

Early on, I wrote a program to track Help Desk calls in COBOL on a Prime 6550.  I’ve also wrote a utility to export specific emails from Outlook and route them to be printed automatically and stored.  Additionally, I’ve developed utilities to assist in the management of systems, specifically to accommodate a uniquely designed system.

More recently, I’ve been thinking about developing some sites based on ideas that I’ve been floating around for some time.  For several months, I’ve debated which technology to use for the development.  .Net?  Perl?  Java?  PHP?  ROR?

It is commonly known that Nashville is a .Net city, so at first I chose the .Net technology.  I headed down the path, got the right books, watched the right web casts, but I stalled on three items.

First, the cost of deployment.  While I know there are solutions that offer cheap hosting for .Net, there is a point at which an application cannot scale using cheap hosting and would then require some what of an investment (specifically SQL Server).

Granted you could use alternative database servers.  However, this deviates from all of the tutorials and books that I’ve explored.  Keep in mind, I am not a full time programmer, so for me all of this is done in my spare time.  So, using an alternative database adds complications that I would have to sort through.

Finally, I’m taking a “slow cooker” approach on these apps.  I’m taking my time developing them – learning as I go – and a few are more of a hobby than a business.

Second, too many distractions.  For example, what is the best way to write to the database?  Use SPs?  Use in-line SQL?  Use LINQ?  Given there are a bunch of people with opinions on each of these approaches, I have no way of knowing what is best for what I’m doing.  I spent more time reading articles than planning the design of the site.

Third, the books I just purchased are out of date!  (I exaggerate, of course).  So, I started looking at ASP .NET 2.0 a while back.  Then 3.0 came out and then 3.5.  So, do I use LINQ?  WPF?  WCF?  WF?  MVC?  Again, keep in mind, I’m not a full time programmer, so I had a difficult keeping up.

So, I decided to choose Ruby on Rails.  Why?  I just finished working on a project involving LAMP and I really enjoyed it.  Second, I appreciate the convention over configuration aspect.  Third, this allows me to spin up these apps at a low cost over time.

In my next post, I’ll share with you the materials I’m using to learn Ruby on Rails.

Andrew Development , , , , ,