Getting started with React.Js using NPM

My assumptions: You have prior experience of Web framework like 
  Ruby on Rails, Django, Phoenix, etc. 
Please refer to this React.js style guide for community comprehensible source code.

Hey, its not mandatory to use NPM to build applications with ReactJs; but, it will be alot easier to build, maintain, share codes using NPM. Firstly you should have NodeJs installed in your development machine.

Installation for Development Environment

$ sudo apt-get install nodejs
# try 
$ node -v
# v4.2.6
# if its says command not found: node then try 
$ nodejs
# If it shows up, it means due no some name conflicts 
# the name/command node is already taken by some binary. 
# So, its get it back.
$ sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10

Probable Issues: NPM not found

Continue reading


Rails : i18n : unexpected redirections

In my app, I have different User types like VehicleOwner , GarageOwner, Admin and unidentified/unauthenticated. I wanted to implement localization for English and Finnish. I was successful, but suddenly all my old URLs stopped working; when I tried to access the old URLs I was redirected to login page, and the login page was also not loading – stuck on infinite redirection loop.

# Initial implementation
unauthenticated :user do
  get '/:locale' => 'pages#home'
  root 'pages#home', page: :home

authenticate :user, ->(user) { user.vehicle_owner? } do
  get '/:locale' => 'vehicle_owners/quote_requests#index'
  root 'vehicle_owners/quote_requests#index'

authenticate :user, ->(user) { user.garage_owner? } do
  get '/:locale' => 'garage_owners/quote_requests#index'
  root 'garage_owners/quote_requests#index'


unauthenticated :user do
  get '/:locale' => 'pages#home', locale: /en|fi/
  root 'pages#home', page: :home

authenticate :user, ->(user) { user.vehicle_owner? } do
  get '/:locale' => 'vehicle_owners/quote_requests#index', locale: /en|fi/ # because should be addressed
  root 'vehicle_owners/quote_requests#index'

authenticate :user, ->(user) { user.garage_owner? } do
  get '/:locale' => 'garage_owners/quote_requests#index', locale: /en|fi/
  root 'garage_owners/quote_requests#index'

Issues with Stripe : Mock and solutions

undefined method `api_key=’ for StripeMock:Module

Looks like we dont need to pass API_KEYs if everything we are going to mock everything.

Stripe::InvalidRequestError: No such plan: thepact_monthly

Create a mock plan like

plan_params = {:id => 'thepact_monthly',
               :name => 'StripeMock Default Plan ID',
               :amount => 1900,
               :currency => 'usd',
               :interval => 'month'}

Stripe::InvalidRequestError: You must supply a valid card xoxo

You need to pass ‘source’ attribute as well

subscription = customer.subscriptions.create(
        plan: 'thepact_monthly',
        source: stripe_helper.generate_card_token({name: 'Shiva'})