Jeremy Durham

Ruby, Rails, and everything in between.

  • BlogThoughts
  • AboutAbout the Author
  • ContactGet in touch

December 24, 2005 12:20
Posted by Jeremy Durham

Getting acquainted with Ruby/Rails

Recently, I introduced two of my programmer friends to Ruby on Rails.

After I got back to them to see what their progress was, they both informed me that they had given up. They echoed the same problem: Not enough documentation, too difficult to get started.

Although it’s difficult to look back and say how difficult or easy it was to get started, it is easy to tell what I use on a day-to-day basis now during my Rails development. Here they are:

  • The Rails Book – At $22 for the PDF version, this book was initially my best reference for Rails development.
  • The Pickaxe Book – An excellent reference for many of your Ruby questions. Although knowing Ruby well isn’t a requirement, it will definetly help you understand Rails.
  • Rails API Documentation – I generally use this only to find out what parameters a method takes. I mistakenly used this for a lot of examples early, but I personally feel there was always a small gap between these examples and what I was trying to do.
  • Ruby Documentation – Even though Rails gives you a lot, sometimes you still need to be able to split, join, chomp, collect, etc. This will give you the ‘skinny’ on how it’s done in a hurry.
  • Typo – Download and review this source code. There’s no better source for real-world example at this time, in my opinion. I was fortunate that Jack made this excellent suggestion to me.
  • Code Snippets – Although I don’t specifically have this site bookmarked, I’ve ended up here enough times to give it good mention. From there I got the snippet on paginating collections, the rss feed example, among other things.
  • IRC Channel – #rubyonrails on Freenode. A great place to bounce ideas or ask general questions, with instant feedback.

No Comments

Posted Under Programming

January 01, 2006 17:59
Posted by Jeremy Durham

OSX, Rails, and Locomotive

If you’re attempting to get Rails running on the Mac, do one of the following:

  • Use Locomotive (This is the preferred way)
  • Use This great how-to and install it manually. This will require things like the developer tools.

If I was only going to change one thing about this great how-to, it’s that if you try to build the mysql native buildings again mysql 64-bit, it will NOT work. The error will be:

@ /usr/bin/ld: truncated or malformed archive: /usr/local/mysql/lib/libmysqlclient.a (ranlib structures in table of contents extends past the end of the table of contents, canÕt load from it) @

Fix this by running:

  • @ ranlib /usr/local/mysql/lib/libmysqlclient.a @
  • installing the 32-bit version of mysql and building the bindings with that.

either of these should work.

No Comments

Posted Under Programming

January 09, 2006 08:16
Posted by Jeremy Durham

observe_field and request.raw_post

A few applications I’ve been a part of have use an observe_field for product description previews, or even my blog (to allow me to preview my posts). If I ever work on this site, comment preview will probably use observe_field.

Anyways, I always just used request.raw_post in the controller to catch the posted data and process it. You can use the :with option in observe_field to pass it as a normal param. :with works like this:

<%= observe_field "product_description", 
                  :frequency => 2, 
                  :update => "preview", 
                  :complete => "Element.show('preview')", 
                  :url => { :action => "preview" }, 
                  :with => "'q='+escape(value)" %> 

Your params will look something like this:

@ {"action"=>"preview", “q”=>"whateveryoutyped", “controller”=>"products"} @

No Comments

Posted Under Programming

January 22, 2006 22:10
Posted by Jeremy Durham

Returning more than one object

So, apparently I’ve been living under a rock, but no one told me you could return more than one object at a time in Ruby. Take for example:

def return_stuff
  u = User.find :all
  o = Order.find :all
  return [u,o]
end

and this snippet:

u,o = return_stuff

Now, granted, you probably want to use this when dealing with two items that are a bit more, related to each other, but nonetheless, very cool.

No Comments

Posted Under Programming

January 23, 2006 20:12
Posted by Jeremy Durham

Ruby/Rails sweetness

Alright, I hate stealing from other people, but I found this on projectionist and HAD to repost it. It’s for generating a “BETWEEN date1 and date2” SQL fragment:

(6.months.ago.to_date..1.year.ago.to_date).to_s(:db)

Which produces:

=> "BETWEEN '2005-07-28' AND '2005-01-23'"

OK, that is seriously too sweet.

No Comments

Posted Under Programming

February 06, 2006 20:44
Posted by Jeremy Durham

Switchtower deployment to development environment, Part 1

I have an interesting conversation today about how other companies deploy sites to their development environment. The issue is that we want only one person to be able to deploy to live, and basically everyone to be able to deploy to development. The only problem is, in order to deploy to development, you need sudo, specifically for file permissions and restarting the fcgi process. Without giving everyone and their brother sudo, what’s the solution? Well, to be honest, I don’t know, but I’m searching for answers even as I type this…

1 Comments

Posted Under Programming

February 11, 2006 08:26
Posted by Jeremy Durham

Ruby and FPDI

Will someone please rewrite FPDI in Ruby? Thanks.

No Comments

Posted Under Programming

February 25, 2006 22:22
Posted by Jeremy Durham

railsapi.org

Coming soon for all you PHP programmers…

2 Comments

Posted Under Programming

February 27, 2006 18:49
Posted by Jeremy Durham

Rails and ADC

Props to ADC to do an article about Rails that includes screenshots of Textmate!

And straight from their conclusion:

“Ruby on Rails is a highly-productive and industrial-strength web application framework. It scales from the simplest expense tracking application we built to full-featured applications with respectable numbers of users. As with any useful tool, it’s not suited to handle every job, but it’s a great complement to your Mac OS X development environment.”

Read more about it…

No Comments

Posted Under Programming

March 12, 2006 19:58
Posted by Jeremy Durham

REST on Rails

If you’re interested in making your Rails app more REST friendly, check out RESTifarian

1 Comments

Posted Under Programming

  • Posts
  • Twitter
  • Flickr
 

Capybara + parall...

Programming

 

CI rerun

Programming

 

New gem - Seed

Programming

How is it the Lions have the 13th toughest schedule in the NFL when they were 2-14 last year? Right between The Ravens and the Bears.

follow me on
twitter

125942640_a3dcc3f951_s125942637_c4524c7c88_s125942628_a682f8a639_s122144184_5f2dd86929_s122144182_1b01ded312_s122144181_893a82f1d3_s122144179_70465b00ff_s122102402_21e6174af6_s122102401_f6d9ebff55_s

Categories

  • Technology
  • Programming
  • Family
  • Travel

This site is using the Handgloves WordPress Theme
Designed & Developed by George Wiscombe

Subscribe via RSS