Category Archives: Ruby-on-Rails

Rails #6: Grant edit access to select users

In my last article, I showed how to implement authentication with Ruby on Rails. But security is about more than simple login. For many applications, we want to grant permission to manipulate a resource to a set of users. In this article, I will guide you though adding functionality so that users can modify the permissions for who gets to edit an article.


Posted in Ruby-on-Rails | Leave a comment

Rails #5: Security

In my previous articles, I have showed you how to create a simple blog application with articles, comments, rss feeds and formatting. However, as it is currently written, the application allows for anyone to create or edit an article. This is a serious security issue, and we better fix it.

In this tutorial, I will show you how to make sure that only logged in users can create articles, and that nobody else can edit an article that you created.


Posted in Ruby-on-Rails | Leave a comment

Rails #1b: Heroku

If you though getting started with Rails seemed easy from my first post, you haven’t tried out Heroku yet. Heroku is a hosted solution for Rails that comes with a browser based IDE. There’s nothing to install. It is so easy that it’s almost ridiculous. To me, this is the future of application hosting.

One of the remarkable things about Rails is that it lets you get up and running very quickly. Here is what you need to do to get your first application up and running on Heroku.


Posted in Ruby-on-Rails, Technology | 13 Comments

Rails #4: A real blog

This is the fourth article in my introduction to Rails. In the previous articles, we created a web application that let us edit articles, added support for comments to our articles, and added some nice AJAX effects. But a real blog needs feeds, a decent front page and some article formatting. In this article we will add all these. The article contains no groundbreaking features, but mostly dots a few i’s and crosses a few t’s both when it comes to the blog we’re building, and details in Rails.


Posted in Ruby-on-Rails | Leave a comment

Rails intro #2: One-to-many relationships

In my last article, I showed you how to get started with your Rails application. The result of the simple commands, rails blogdemo; cd blogdemo; ruby script/generate scaffold article title:string author:string content:text; rake db:migrate; ruby script/server was that you had your own simple blog up and running. The blog support articles each of which have a title, an author, and text content. This initial model was generated for us with no editing on our part.

In this second article, I will expand the blog to allow comments to our articles. This will require us to get our hands a bit more dirty with the Rails code, but it won’t be too bad. And even better: If you complete the instructions in this article, you can call yourself a Rails programmer!

Are you ready to dive in head first?


Posted in Ruby-on-Rails | 4 Comments

Rails Intro #1: A data management application in five easy steps

I am planning to write a series of articles on how to get started with Ruby on Rails. One of the remarkable things about Rails is that it lets you get up and running very quickly. Here is what you need to do to get your first application up and running.

Before you start, you need to install Ruby on Rails: On Macs, Rails is already available and you can type the following commands in a normal terminal window. On Windows, you can get everything you need from InstantRails. Once you have unpacked InstantRails to a subfolder, start the “InstantRails.exe”. From the GUI that comes up, click the “I” button in the top left corner and select “Rails Applications” -> “Open Ruby Console Window” from the menu. The following commands should be typed in the command line window that shows up.

  1. rails blogdemo
  2. cd blogdemo
  3. (Optional: Look at how generators work – read the documentation that is printed) ruby script/generate
  4. (Optional: Look at how generators work – read the documentation that is printed) ruby script/generate scaffold
  5. ruby script/generate scaffold article title:string author:string content:text
  6. (Optional: Look for the documentation on the “rake” command) rake --tasks
  7. (Optional: Look for the documentation on the “rake” command) rake -T db
  8. rake db:create:all
  9. rake db:migrate
  10. (Optional: Load generated test data into the database) rake db:fixtures:load
  11. (Optional: Run the generated tests) rake test
  12. ruby script/server
  13. You should now be able to view your wonderful application at http://localhost:3000/articles
  14. Be sure to read the documentation at http://localhost:3000/ as well

Enjoy your first rails application!

Generated article list

If you find the results satisfying, you should start by exploring the directory structure of the files generated by Rails. In my next article, I will tell you how to generate more advanced data structures, so that we can add comments to our blog articles. (Still to come future: How to setup a server and deploy to it, tips on working with your code, exploring the rails structure, AJAX, and RSS feeds)

Posted in Ruby-on-Rails | 8 Comments

“Smidig 2007”: A conference for the community

The Norwegian word “smidig” means “agile”. So when we wanted to make a Norwegian conference for the Oslo Agile community, “smidig 2007” (November 26th and 27th) was a natural choice for a title.

The seed of the conference was idea by Nils Christian Haugen and Aslak Hellesøy to have a whole day devoted to open spaces. Meanwhile, I had been experimenting with “lightning talks” on Oslo XP meetup, a user group that meets in Oslo every month. The inception of the open spaces conference was delayed over the summer, and towards the end of the summer, Trond Pedersen and myself were discussing the success of the Oslo XP meetup lightning talks over a beer. The more we thought about it, the more it seemed natural: We need a whole day devoted to lighting talks. Meanwhile, Simen Fure Jørgensen decided to start up Oslo Lean Meetup.

We tossed the ideas around on the forum for a while, and Christian Hauknes noticed how disorganized we all were about it, and decided to make it all come together. Along the way, many enthusiasts have contributed. Without them, it would all still be a fantasy in the minds of a few people.

Finally, we all came together with a single vision: A two day conference for the community, by the community. We know that there are a lot of people with extremely valuable experience who seldom get heard. Instead, conferences focus on big names that tend to overshadow the participants.

We hope that Smidig 2007 will be different. Both days of the conference are devoted to ways to get the participants to learn from each other. Open spaces workshops allows for in depth exploration of topics and experiences, while Lightning Talks, a presentation form that limits all talks to 10 minutes, allows for a wide range of point of view and experience.

Over 50 speakers have already signed up. For a conference where we expect a total of not much more than 200 participants, this is great. I’m overwhelmed by the great support of the business community. Over 20 sponsors have signed up, ensuring that we won’t go broke in the process of pulling together this conference. We have the budget to pull of a spectacular conference dinner, video recording of the whole event, and the most interesting venue in all of Oslo.

There are still a lot of things that could be improved. If you read this blog, and you would like to play around with the Rails-based conference application, organize a conference dinner, organize an open space conference, write about the conference, discuss experiences using agile principles on the forum, or help move chairs and table around during the conference, we would like your help. Or even better: If you yourself see room for improvement. Send an email to the conference mailing list to get in touch with us.

I have always been impressed by the insights of Oslo software professionals. I am looking forward to hearing a dozens of them speak in November.

Posted in Communities, Ruby-on-Rails, Software Development | 1 Comment

Rails: The Demonstration

I often criticize products from the big vendors like IBM, Microsoft and Oracle for what I call the “New Coke Effect”. As retold by Malcom Gladwell in Blink, Pepsi introduced blind taste tests in the 80s. They beat Coca Cola by a big margin. In order to regain the advantage, Coke developed “New Coke”, a product that was optimized for the blind taste tests. It tanked. Totally. It tanked so bad that coke had to have the words “classic coke” prominently on the label until 2002.

The problem is that a blind taste test is not the same as drinking a whole bottle. People prefer sweet tastes when they just take a sip, but not when they want to finish the glass.


Posted in Ruby-on-Rails | 6 Comments