Notes From a Full Stack Developer
on Rails, ActiveRecord, Hidden Attributes

Hidden Model Attributes

Sometimes we have some attributes of model that should not to be available for client (via json format, javascript variables...), such as: password, login count, secret token... When we do render json: @visitor, Rails will return to client like this: { id: 1, secret_token: "iHj-Psm45Ymge-7kZNyx", name: "Test
Read More
on Gon, JS Rails Variables

Bring Rails data to javascript with Gon

Using Rails data in javascript is a very common need, especially for SPA (Single Page Application) with AngularJS, Backbone.js, Ember... or only pure javascript applications. We have some ways to make this Assign to javascipt variable in views #/views/layouts/application.html.erb <script type="text/javascript&
Read More
on No Rdoc, No Ri, Skip Documents With Bundler, Skip Gem Document

How to skip gem documents (ri, rdoc) installation

By default, RubyGems will install documents (ri, rdoc) together with gem when you install gem. It happens for both gem install and installing with bundler. Almost ruby developers will want to skip documents installation because they are usually useless with us and it takes time to install, specially when we
Read More
on Rails 4.2, Rails, Rails Server, Rails 4.2 Remote Access

Make Rails 4.2 server listens to all interfaces

After upgrading Rails to 4.2, you cannot access the development mode rails server from another computer/virtual machine (remote access) for testing. So, why can this happen and how to resolve it? Reason This is caused by a change in Rails 4.2, the rails s command no longer
Read More