Sunday, December 17, 2017

Rails vs Padrino or others

Starting writing in Ruby after touching all other languages is like finding manna as the life saver. Talking about Ruby, the one web framework that comes to mind is Rails. I will not talk about Padrino or others until a while. Let me try to put the reasons on why you should use rails

1. Large community base - building or adding features and bug fixes continuously gives it capability to have the latest web technologies be it like front end technology like sass, bootstrap and all.

2. ‎Automatated generators - almost every MVC part generation is automated, be it creating controllers, adding or updating models, creating views with ERB (try haml too) adding tests, rake tasks and much more, all from the command line. I recommend using Linux ( Manjaro ) with rbenv to manage ruby environments and of course VIM editor with tmux for ide like multitasking. I prefer solarized light theme for them 😀

3. ‎Rails console - gives the easy shell to check your variables, url params, perform database CRUD operation methods, session values, "string".classname to get inherited classes or modules and all

4. Github and Heroku deploy - Using one branch for each task and merging them to master once done is the way to go. Lastly the deployment is as easy as single command 'git push heroku' which pushes the master branch to Heroku. Heroku generates an url for your application. Also it supports postgres for now, so watch out for it when starting to build your app.

That's it, this is what it should take for you to get going with your loved programming language on the best automated web framework.

Roughly you would be adding the routes in the config/routes file. It's controller will be an ApplicationController class in app/controllers/name with methods or actions like index, create, show, delete or similar. Finally the render for views is in app/views/name as .ERB file for each controller (class) created. These can be further broken down using partials using underscores like _footer.erb or _ header.erb . One can further use HAML instead of ERB for minimal writing. Of course you can use SASS or SCSS and coffee script for JS.

I recommend reading or referring Michael Hartl's Rails book, it's a pretty good book for a first time web developer. The recommend chapters are static pages ....

If you read till now, I am pretty sure you will stick to rails for a while. Now let me talk about its competition. One I think of is Padrino which is built on top of Sinatra mini web framework.

Sinatra doesn't have a routes but instead have their routes defined in the controller class itself. Padrino has a lot of work in progress parts but shows off the light weight benefits.

Padrino imports lot of rails generator concepts for creating controllers, tests, models, views and all. The blog tutorial on its site uses sequel which I didn't want to start learning as I just learnt Activerecord which uses such easy methods like User.find_by_name("Ragavendra") to retrieve say user records and say .save , . create and .delete to fulfill CRUD.

 I assume Activerecord was created by the Rails team. There are a tonne more libraries contributed by the rails team to the Ruby community as gems or even to its core. Rails is what more or less made Ruby popular. Lot other modern web frameworks have inherited Ruby gem concepts as well for easier web development.

Spree is an ecommerce built on top of rails. Hanami seems easier and imports a lot of rails like commands, it has a lot of nitty gritty which feels like working on HTML for some reason. I am pretty sure you will want to fall back to rails like me if you walk through all the other web frameworks. The best part is the sane eco system it has to offer.

The tests part is one which I wouldn't recommend and DHH thinks the same too, it takes to much time and stresses real bad. Better to have a separate team write integration tests than those painful TDD or unit tests.

Browser background color or monitor brightness

Have you been in a situation where you are almost sitting the whole day in front of your browser and going through a document and find that ...