I had to setup continous deployment for my Rails application with Capistrano 3. The application is hosted in AWS ubuntu. Beanstalk frustrated me for a long time, so i decided to use Capistrano 3 deployment tool.
One of the issues that developers who have used Capistrano 3 are bound to face is /usr/bin/env XXXX not installed. I am not going to get into why you get this issue as there is lots written about it. But I think the solutions to this are not highlighted clearly. In the Capistrano 3 documentation, ‘Command Mapping’ is the section that we need to go through, for clearing this one.
Since Capistrano 3 runns bundle, rake, ruby commands we may have to configure the path of these tools in the Capistrano config file; ie., deploy.rb.
I configured the path like this
set :default_env, {
path: "/usr/share/rvm/rubies/ruby-2.2.1/bin:/home/ubuntu/.rvm/gems/ruby-2.2.1/bin:$PATH",
'GEM_HOME' => '~/.rvm/gems/ruby-2.2.1/',
'GEM_PATH' => '~/.rvm/gems/ruby-2.2.1/gems'
}
Also, you can configure the SSHKit mapping for rake and bundle commands like this,
SSHKit.config.command_map[:bundle] = "~/.rvm/gems/ruby-2.2.1/bin/bundle"
SSHKit.config.command_map[:rake] = "~/.rvm/gems/ruby-2.2.1/bin/rake"
This solves the problem really fast as the SSHKit now that connects to your Ubuntu instance uses these paths.
2015 was busy with several months of travel. I met a number of smart people from who I learnt a lot. And yes, dabbled with a several tools, languages and frameworks. Here’s a list of things I did in the professional front.
- The new language that I got a chance to use was CoffeeScript. Indentation drove me crazy initially, but then started loving it.
- The new technology that I learnt and used extensively was ElasticSearch. My foray into Big Data started with ElasticSearch. And it helped me gain very good clarity in this front.
- The one and only editor I used was Textmate
- Used Ruby, Groovy and Scala for a number of utilities that improved productivity. JavaScript remained the most used language last year, however.
- Read atleast one technical book every week, thanks to Kindle. My favourite for the year was ‘Programming Clojure’ by Stuart Halloway
- Attended just two conferences last year, which included a workshop on Microservices architecture.
- My favourite sites for hunting top talent were Upwork and Fiverr.
- The Continuous Integration/Deployment tool that I used for most of my work was Semaphore
- I was hooked on to Courseera for mastering core Computer Science concepts
- We closed down HealthyCode magazine, despite excellent reviews, because of the blood bath. But the learning was remarkable. How else would I have got a chance to meet people like Richard Stallman, Bruce Tate and several great minds, if not for the magazine? They literally reshaped me in the first half of the year.
- I worked in two products. One was technically very satisfying, but mismanagement of the team killed it. The other one technically very challenging and is still going very strong.
- I wrote fewer blog posts. I hope to improve the number this year.
- I created Table of Contents on two technologies that I wanted to write for my third book. But didn’t find the correct time and match for taking it forward.
- I drifted away from Java even further.
A couple of months back my colleague and I hit upon an idea during a casual conversation. After continuous travel assignments, we took a break and started evaluating our idea seriously. After several discussions over a number of cups of coffee and tea, we finalized on building a prototype.
I have clearly moved away from the idea of hiring people for any development work and having them in our premises. I believe the modern day development happens in UpWork, Fiverr, Elance and TopTal sites. We are definitely not interested in bringing elephants and feeding them in our office, anymore.
We developed the rough cut design(wireframes) and found an UX designer from Ukraine. The guy did a fantastic job of designing it and handed over the deliverables in less than a week. I identified a Bootstrap developer from Bangladesh. The developer delivered static pages implemented using Bootstrap. He completed the job in 3 days time.
I took the static pages and injected dynamic behaviour using Rails, jQuery and ElasticSearch. Needless to say, I developed the prototype too, using TDD. Finally we hosted it in a Ubuntu instance in AWS.
Though I don’t blog much on Rails, I always consider Ruby on Rails to be the darling of new ideas 
The last one and a half months was feverishly exciting; nurturing an idea, evaluating it, numerous discussions, interacting with developers from different countries, creating a working prototype and finally pushing it to the cloud.
The day after we wrapped it up, it started pouring in Chennai. 
I have been pretty busy last few weeks have churning out test cases with Angular JS. And we use Jasmine for unit testing and Karma JS for automating unit tests. For the sake of setting up each developer’s machine with all these tools, I created a simple list of instructions and floated it around. And here we go.
- Install Node JS
- Create a project say MyApp
- Navigate to MyApp in the Terminal or Cmd
- Run npm install angular
- Run npm install angular-mocks
- Run npm -g install karma
- Run npm -g install karma-cli
- Run npm -g install karma-jasmine
- Run npm -g install karma-chrome-launcher
- Run karma init
- Modify the karma.conf.js to include the angular js src files and the jasmine specs
- Run karma start karma.conf.js
Ext JS 4 provides MVC support where we create a Controller for a collection of Views and Models. The usual confusion to this approach, is how many controllers do you require in an application. The general approach is one controller per use-case.
So if you have to add/edit employee details, you’ll have one View for each and one Controller for all the Views.
[app]
[view]
- AddEmployeePanel.js
- EmployeeDetailsPanel.js
[controller]
- EmployeeController.js
Usually, developers argue with this style and try to create one Controller for each View. The Controller can get really crowded and clumsy as it will have code related to several views. Unit testing these controllers is also a pain.
With Ext JS 5( so in 6 too), with the introduction of ViewControllers, this confusion doesn’t exist now. You can create a View and have one ViewController per View and also a ViewModel per view. So the relationship is one-to-one with View and ViewController, and this solves lot of design issues. For the Employee example, this is how the file structure would look like.
[app]
[view]
- [employee]
-AddEmployeePanel.js
-AddEmployeeViewController.js
-EmployeeDetailsPanel.js
-EmployeeDetailsViewController.js
We really don’t have to worry about creating Controller classes anymore, though I would like to sort-of move the navigation logic to the Global controllers. Personally, I find ViewController to be lot more easy and straightforward to design and implement.