Faalis v2

21 Dec 2015

It's been about a year since we started working on the second major version of Faalis and finally we released v2 yesterday. This release introduce a complete set of new features something near a rewrite.

What changed

Let's take a look at changes in compare to previous versions.

Dashboard Interface & Turbolinks

Maybe the most important change introduced in v2.x in compare to 0.x, and 1.x is the new dashboard. Previous dashboard system was a javascript application based on AngularJS library. At first when we developed the old dashboard, world still did not find out about the dark side of AngularJS and every one was so happy with it, but after a while every one including us begin to realise that AngularJS 1.x has some very serious issues. For example "angular world" was a huge pain in the ass. Long story short we decided to not to continue with AngularJS. Our most important reasons were:

  • Handling two different application code base takes too much energy.
  • Our assets got too big.
  • We ended up with a giant JS application which was too slow.
  • The damn "Angular World" which caused us lots of work and pain.
  • JS application got complex and after a while debugging it was so hard
  • And finally Turbolinks rocks.

The above reasons were enough to drive me crazy. In that time I suddenly remembered something important by watching @dhh keynote talk on RailsConf 2015. I was totally forgot about how awesome Turbolinks can be. In the past I was ignorant about Turbolinks simply because it was'nt that good at the time being.

After spending a little time to update my knowledge about Turbolinks, I get to work and created a very basic prototype of Faalis dashboard to see how can it be helpful to us. After a while it was clear to me as the blue sky that IT'S WHAT WE NEEDED.

Thanks to Turbolinks we get ride of our huge AngularJS application and replaced it with very small amount of javascript code. Our Assets size reduced by about 95% specially in bigger projects. And maaaan it's fast too. But the most awesome experience with turbolinks in compare to "AngularJS" or any other similar frameworks is that it's railsy you just write ruby and js code in rails fasions nothing special. This feels great.

It Faalis 2.x, we re-write dashboard subsystem entirely. Now:

  • It's much smaller
  • It's much faster
  • It's easier to work with dashboard UI API
  • Generate code for each resource reduced to minimum.
  • Everything is in the same Rails application code base.

New dashboard feels great.

Dashboard Interface & AdminLTE

Good folks at almsaeedstudio create a very nice piece of UI for dashboard interfaces aka AdminLTE with free software license. It's beautiful and awesome and uses bootstrap which is pretty popular. So we decided to use AdminLTE instead of our UI interface.

At first we cloned the AdminLTE and made somechanges to use in Faalis but after a while we did the right thing and created a gem called admin_lte-rails (Don't ask about the name, it's awful I know, but it's history :wink:) which uses fantastic rails-assets.org to provide an automatic build and SCSS version of AdminLTE with RTL layout support ( which vanilla AdminLTE does not support). This way we can always be up2date and keep up with AdminLTE version.

Generators

The biggest change in Faalis 2.x is to removal of old generators. If you were a Faalis user back in the 0.x and 1.x versions you remember that we used to have a set of very complex code generators. By giving them a yml or json file, representing our resource they would generate huge amount of code for that resource to work with both of our Rails and AngularJS. They were great and handy in their time but we come to realize that the easier way for developers is meta programming and dynamic codes not some generated static code for each resource. So we removed all the acient history and started fresh.

In Faalis 2.x we have only two generator for generating resource code. The main one is faalis:resource which takes the resource name as an argument and generates a dashboard controller alongside with injecting corresponding routes into routes.rb. All the dashboard controllers inherit indirectly from Faalis::Dashboard::ApplicationController which provides handful set of methods and an easy to use DSL for developers to enhance their resource workflow in dashboard. Basically you only have to take care of translations related to your resource ( don't worry we have a solution for this too :P). Dashboard controllers works with the related resource model. I mean they do their business by extracting necessary information from models. So no extra large generated code base for each resource. This way using and modifying dashboard work flows get 'freakin' easy. Also the provided DSL by Faalis::Dashboard::ApplicationController can be a big deal of help to you in order to enhance your work flow.

The second generator faalis:resources, is just a shortcut for first one. It gets several resource names and generate them using faalis:resource generator.

Make sure to take a look at Faalis guides to get more info about generators.

Authorization

CanCan is a great gem but was not what we are looking for. So we ditched it in favor of Pundit which is fantastic and robust gem designed for flexible authorization. In Faalis 2.x in addition to the old read , create, update, destroy and ownership permissions for each resource, developers can alter the pundit authorize class of each resource base on their desire which gives Faalis a huge advantage on authorization system.

The most important thing to remember is the this new authorization system is backward compatible you only have to generate the pundit authorization class for your resource.

Formtastic

After ditching AngularJS, personally I was checking out different options we had to implement our forms. Among those I reviewed. Formtastic stood on top and we used it in new Faalis. Formtastic is really awesome and easy to use and extend which gives us a great opportunity to define our own input classes on demand.

Conclution

We never released Faalis 1.x officially (as gem I mean, you can use it via github). That's because we done several mistakes which I pointed out some of them in this article. But it gives us a very clear vision about where we want to go in the future. And Faalis 2.x is the result of what we learn alongside the road to 1.x. Personally I found Faalis 2.x fascinating (:)) yeah because I wrote it). It's really handy and can help any developer save lots of his/her time during web development process.

At last I really love to know your opinions on Faalis and its pros/cons. I love to hear about your suggestions or criticisms. I hope you find it plausible.



lxsameer

About Author

A Bad-ass developer who loves programming and enjoy learning new stuff. He is a senior developer in Yellowen and manage some of the Yellowen free software projects. He enjoys software development, Electronics, Training Kyokushin Karate and play music.

Ohloh profile for Sameer Rahmani


comments powered by Disqus