Category Archives: Ruby on Rails

Objective Resource for Faster iPhone Development

I recently came across Objective Resource for developing iPhone applications that talk with a Rails backed website. According to the site,

ObjectiveResource is an Objective-C port of Ruby on Rails’ ActiveResource. It provides a way to serialize objects to and from Rails’ standard RESTful web-services (via XML or JSON) and handles much of the complexity involved with invoking web-services of any language from the iPhone.

I’ve had a chance to play with it this weekend and have found it to be pretty easy to work with. The developers of Objective Resource have created a pretty good Getting Started Guide you can follow, or you can watch a screencast of it as well. They even offer an example project for you to work with that gives you both the iPhone app (via Xcode) and the Rails app so you can see how everything works together.

One thing the example project does not include is accessing a Rails app that has authentication. Of course I was thinking I was all setup for this, but soon realized that I did not add my Active Resource functions in so that my app would work with XML/JSON requests. Luckily, while I was out in Denver, CO for iPhone Development Training (by Pragmatic Studio) I was able to get my hands on a copy of Advanced Rails Recipes by Mike Clark. I was extremely pleased that Mike graciously gave me the copy he had laying there for free. The particular recipe in the book that helped me was the Authenticate REST Clients. After I rewrote my authentication piece of my Rails app, I was getting data back and into my iPhone app. It was a very good feeling!

I thought I would include the screencast that the Objective Resource developers created. It runs about 6 minutes and is definitely worth a watch if you are looking at using Objective Resource for your next iPhone app backed by a Rails app.


Getting Started with Objective Resource from Josh Vickery on Vimeo.

Ruby Vulnerabilities

An Apple Product Security technician has identified multiple vulnerabilities with Ruby, which if exploited could be used in denial of service attacks. It does not have to be just Mac OS X that this afects. It looks like it’s all versions based on the official post from the Ruby development team.  To find out what version of Ruby you are using open up Terminal or your command-line prompt client and type

ruby –version

You should get something like this

ruby 1.8.6 (2008-06-20 patchlevel 230) [i686-darwin9.3.0]

Now you can see that’s I’ve already went ahead and updated my version, so yours might have patch 110 if there was a patch level. To update your Ruby version all you need to do is visit the link above and choose which patch you need to install.  For us Ruby on Rails developers you’ll need to upgrade to Ruby 1.8.6 patch 230. You can download it here and type the following in your command-line prompt.

curl -O ftp://ftp.ruby-lang.org/pub/ruby/1.8/ruby-1.8.6-p230.tar.gz
tar xzvf ruby-1.8.6-p230.tar.gz
cd ruby-1.8.6-p230
./configure –enable-shared –enable-pthread CFLAGS=-D_XOPEN_SOURCE=1
make
sudo make install
cd ..

You can then check your version by typing.

ruby –version

If you have any problems, feel free to comment below.

UPDATE: After posting this I was having a hard time keeping an instance of mongrel running.  I did some searching and found out that the option they have offered us does have a bug still in it.  So what that means is that we either update and have issues or stay at what we’re currently at and deal with the possibility of denial of service attacks.  Keep your eyes posted to the Ruby on Rails blog for an update. I’ll post another update here as well once things are figured out.

To busy to complete…

So I’ve been getting a little busy at work lately, and while I’d like to really take you guys through a ToDo list tutorial, I just don’t have the time right now to work on that, while learning Rails 2.0, and then working on getting a ToDo list app working as well.  Rather than leave you guys high and dry without finishing this, I thought I’d show you this really cool open-source ToDo application that you can install for free!  Check to FooToDo here!! I think you guys will like it.  I’ve played around with this on my Development machine, but not in a Production setting.  From what I’ve been able to tell it looks like it’s no longer being updated (it’s running under an older version of Rails as well).

On other news, I would like to invite anyone in the NOVA/DC area that’s interested in hearing Chad Fowler and Rich Kilmer at the DCRUG meeting this Wednesday, March 26th. Here’s the details:

Date & Time 
Wednesday, March 26
th, 2008, 7:00pm

Refreshments:
Pizza and soda will be provided by Intridea – please RSVP to chris@intridea.com so we can get a headcount.

Location:
The George Washington University
Media and Public Affairs Building
Room B02
805 21st Street NW
Washington, DC
http://www. gwu.edu/~map/hmap/index.cfm?bldg=103

You can also read more about it here. If you’ve got any questions, please feel free to comment and I’ll let you know if I can answer them.

Todo list application with Rails 2.0!

I’ve recently taken a new position doing Rails applications full time (which I’m definitely excited about) however, between myself and the other developer, we’ve decided to go right up to Rails 2.0.2. This of course did not fit with me very well because I haven’t done rails development full time yet, and what rails apps I have done were in 1.2.6 and lower. I haven’t been a good developer because I wasn’t paying attention to all the new features and how they work. Of course I posted awhile back about some of the new updates here, but that’s about all I’ve done with Rails 2.0 until last week when I started my new job.

This is tutorial 1 of a new series I’m creating for making a simple CRM application that you can use for some of your daily tasks. Today we are going to create a simple todo list without writing any code (well to start off with). First create lets create a new app by typing,

rails -d mysql todo (I’m adding -d mysql, because sqlite3 is the default database and I’m using mysql)
cd rails

Next, we need to create our databases so we can type the following with rails 2.0.

rake db:create:all

Now that we’ve created our databases, it’s time to make our controller and model. For this, so that we don’t have to write any code, we’ll go ahead and scaffold this. We’ll type the following.

script/generate scaffold Todo title:string body:text done:boolean due:datetime

We can now migrate our database so we’ll type this.

rake db:migrate

Finally, all we have to do is start our server.

script/server

Then we can go to http://localhost:3000/todos and we’ll see our index page. You know have a working todo list, not very design oriented of course, but you are well on your way to making it yours. I’ve put up the application the way it should look here.

If you are looking for a version of this with pre-2.0 of Rails, you won’t be able to use the “rake db:create:all” command, so you’ll have to make your database another way. In the next tutorial we’ll add a customer database with a custom search so that we can search all your customers. Until next time folks!

New Ruby on Rails Host Makes Awesome Entrance!

Heroku is a new Y Combinator startup that joins the growing number of Ruby on Rails hosts, however this host adds a special step of using your browser to build your apps. You can now create Rails applications inside of your browser. Or if you prefer to use your development environment you can do that as well. Heroku is built using Amazon EC2 service. You have the option to upload your own apps via a tar file, or through their gem and git.

From their website they have an awesome list of features:

  • Instant Deployment
  • Create and Edit Online
  • Integrated Stack
  • Elastic Performance
  • Share and Collaborate
  • Import & Export
  • Full Ruby Environment
  • Gems & Plugins
  • Rails Console
  • Generate Code
  • Painless Migrations
  • Rake Console

But don’t take my word for it, check out their screencasts for more information on how to get things up and going.

Heroku, part of Y Combinator startups from this winter, has been in development since June 2006 and has attracted about 2500 users with around 2000 apps.

I do hope that we start to see some new features like support for subversion, mysql databases, and capistrano based deployment. I look forward to seeing what else comes from them. Please keep these guys in your rails radar.

I’ve got my account setup and played with it for a few hours today. If you would like to give it a try, they have a small waiting list, however if you send me an email I can work on sending you an invite faster. Feel free to send me an email at ajmorris2002[at]gmail.com for an invite.

Ruby on Rails Instructions Released for Leopard

Dan over at Hivelogic released an updated guide for installing Ruby, Rails Gems, Rails, and MySQL. Check out the article here. If there’s anything else that you need to install (like RSpec, Capistrano, SVN) you can do that with the following commands.

To install RSpec just type:

$ gem install rspec

To install Capistrano, type:

$ gem install capistrano

To install SVN it’s a little different, so you’ll have to install with the following command:

$ curl -O http://subversion.tigris.org/downloads/subversion-1.4.3.tar.gz
curl -O http://subversion.tigris.org/downloads/subversion-deps-1.4.3.tar.gz
tar xzvf subversion-1.4.3.tar.gz
tar xzvf subversion-deps-1.4.3.tar.gz
cd subversion-1.4.3
./configure –prefix=/usr/local –with-openssl –with-ssl with-zlib
make
sudo make install
Once you have everything is done you should be all set. If you want to check out any other gems, check out this site http://gems.rubyforge.org/gems/.