Introduction

So this morning I started with rails and created my first application, of course this had to be an hello world type of application. Now I would like to make something a bit more challenging. A plant database with a name, the height and the color of that plant. I said a bit challenging not very challenging. But it was challenging enough.

Scaffold

I would recommend reading this guide to get more of the details.

I decided to use scaffold to make this quick and easy. And in rubymine you do this via Tools > Run rails generator… and then you fill in the model like the below.

which then creates a model, controllers, helpers, views, a database script, …

And then it is time to run our application and see if it works.

And that wasn’t the desired result.

For some reason my table was not created. So I did a rake db:migrate from the commandline and found there was an error with my rake version and found that I was not the only one with this problem on stackoverflow.

Here is the error.

rake aborted!

uninitialized constant Rake::DSL

and yes a gem install rake -v=0.9.2 and a bundle update later I could do a rake db:migrate and see this.

There is nothing that makes a man more happy then seeing that it works.

So back to running the server and going to my site and the route in this case is plants not plant.

and I can add a plant.

And then the list looks like this.

Conclusion

If everything works it is pretty simple to make something new. This can be used to make something simple really fast, no idea how it will work if you want something a bit more difficult. What you would certainly use this for is to look at the code it produces and what you can learn from that.