Fast Rails app prototyping published on 23 Jan 2013, 2 minute read
There are often times when you have an idea that will refuse to leave your mind. It is the most beautiful sensation you can ever have. As an any other idea, you must first see it shape before you can throw it away. At this point it is the most important to establish a very effective and noise free channel between your idea and its implementation. I will describe what I use and what I do to quickly make small Rails apps, and what I use for it.
git clone git@github.com:alisnic/naked_rail.git myapp
cd myapp
rm -rf .git
git init && git add . && git commit -a -m "initial commit"
Prototyping
I use an app template for all my new apps. As many things that I created, it was done to write less, and includes the following libs:
- HAML + SASS + CoffeeScript
- Twitter Bootstrap
- PagesController which renders its action. To add a view, all I need to do is to create a
foo.haml
file inapp/views/pages
, and it will be accessible at/pages/foo
. No new routes, no new controllers. You first idea is static. - guard-livereload. I have a vim window alongside the browser on my FullHD monitor. Every time I change the code, the page reloads automatically. This is very convenient, especially when writing the markup.
- flash and error partials. To show a model validation errors in a form, all I have to do is add
render 'validation_errors', :resource => @entity
- better_errors. Really cool gem, makes breaking things pleasant. It will open a ruby shell in the context of the error in the browser.
Growing
If my idea proved strong and stable, I have the tools to grow on the code I made in the prototyping step, and by that I mean I have all the testing tools I need:
- Rspec
- Capybara-webkit (can execute JS) + navigation steps
- Shoulda. Testing models is plain easy and straightforward. The main idea - don’t test ActiveRecord, it has been tested for you. (ex:
it { should belong_to(:user) }
) - FactoryGirl
Final note
I have presented a set of tools and practices to create a Rails app fast. As many other things out there, it is highly opinionated. Also, the repo which I created is not licensed in any way, so do whatever the hell to want to do with it.
Read more posts
- On logic in a Rails app, revisited 6 years later 18 May 2019
- Fitting the "339 bytes of responsive CSS" in a tweet, with a twist 17 May 2019
- Enforcing that a ruby method is called from a specific location 28 Jun 2017
- Log filename, line and function name in ruby automatically 11 May 2013
- Unity performance tweaks 20 Mar 2013
← back to homepage