Coding tips, news and updates for developers....... developers........ developers........... developers........

Dec 21, 2015

Get started with Ruby on Rails '5.0.0.beta1'

gem install rails -v '5.0.0.beta1'gem update --systemrails _5.0.0.beta1_ new mynewapp -d postgresql
Aug 12, 2015

Rails Postgres add auto increment column

class AdddesignsId < ActiveRecord::Migration def self.up add_column :designs, :custom_id, :integer execute < CREATE SEQUENCE...
Jan 08, 2015

Rails add a update change log for Active Record model object

This may come in handy if you want to keep a track on what happened to your database records over time. As you know database is where the Active...
Jan 07, 2015

Clone or copy a PostgreSQL database in Production

Firstly how to clone in the database on the server sideconnect to your database with psql command (bellow is how to for a Amazon RDS instance)psql...
Dec 18, 2014

Rails and Bower for assets mangement

This is how to utilise Bower to install/add external JavaScript or CSS packages to a Rails applicatioin without using any Gems. Firstly make sure...
Dec 04, 2014

Mac Yosemite, Rails, Phusion Passenger and Apache

If you ask me, whats your preffred Ruby on Rails server, without thinking twice I'd say "Phusion Passenger".  Why you may ask, Weeeel to start with...
Nov 21, 2014

Rails mintiest test associations

Say you have users and a user has many ordersIn you test/models/user.rb test "user orders association" do      assert_equal 2, ...
Nov 14, 2014

Mac: giving permission to user - directories

sudo chown -R username:admin /usr/local/bin
Nov 12, 2014

Ruby get a list of responses for an objects instance methods

a = {}(cls_obj.methods - Object.methods).each do |m| begin a[m.to_s] = cls_obj.send(m.to_s).to_s rescue => e a [m.to_s] = e ...
Oct 29, 2014

bundler: command not found: rails

This is how I rails c in productioncd /var/www/iamfreesite/current && /usr/local/bin/bundle exec rails c productionif you get an error like...
Oct 21, 2014

Rails console run code from file

Say you don't like to type in Rails console or Ruby's IRB(Interactive Ruby Shell) and rather user your text editor to write commands and run that...
Oct 15, 2014

Ruby project get started with minitest and bundler

This could be used to create a Ruby gem as well as an  Ruby program. To get the directory structure ready as well as rake tasks and testing working...
Oct 10, 2014

CURL, Ruby on Rails, forms and testing forms with CURL

Get the cookie and save it locallycurl http://iamfree.com/notes/new  --cookie-jar cookie | grep csrf Then post the formcurl -d...
Oct 06, 2014

Synchronizing files with servers with SSH keys - Transfer files between servers

rsync -rave "ssh -i /User/hellome/myssh_key/thesshkey.pem" /Users/antmac/raislapps/iamfree/public/assets --rsync-path="sudo rsync" ssh -i ssh -i...
Oct 01, 2014

Ruby on Rails null or nil querry

Design.where("business_name IS NULL || business_name = ''") With PostgreSQLDesign.where("business_name IS NULL or CAST(business_name as text) =...
Sep 29, 2014

Rails add query parameters to format to link_to

:csv }.merge(params )) %> to add extra information :csv }.merge(params)), :class => "btn btn-default " %> or to...
Sep 29, 2014

Rails, Load Balancers and permanent Health Check URL

Load  Balancers has this tendency to do health checks now and then. With Amazon EC2 Load Balancers it is set at default for once every 30 second...
Sep 17, 2014

List of external IPs connected to my ok computer

netstat -an | grep ESTABLISHED | awk '{print $5}' | awk -F: '{print $1}' | sort | uniq -c | awk '{ printf("%s\t%s\t",$2,$1) ; for (i = 0; i <...
Jul 03, 2014

JQuery add more data to serialized data for AJAX

So if you get a serialized hash from a form submission or other means and want to add more information before you you send it to your headache free...
Jun 21, 2014

Rails test a single directory or section

To test a single directory rather than the entire test suite. e.g  to test your beautiful "test/models"  directory say:rake test:modelsIf you want...
Jun 15, 2014

Rails - JSON views

Rails has this awesomeness to render views- partials as JSON.Say you like to click on the new form and render that form in the same page and inject...
Jun 09, 2014

Ruby on Rails Cron Jobs OpsWroks or on any server

If you are using Amazon OpsWork there are two ways to do a Cron Job (here it is for a Ruby on Rails application). One being  log in to server write...