Posts

Showing posts from December, 2014

How To Setup Ruby on Rails with Postgres

Postgres is a great open source database management system. It's pretty easy to use postgres with Ruby on Rails. Step 1: Install postgress in your system. If you already have postgres installed in your system then skip it else follow the  link . Step 2: Create new project rails new pg_demo You can also create using rails new pg_demo --database=postgresql Step 3: include the pg gem in your gem file gem 'pg' Step 4: run bundle command bundle Step 5: It will give you some error like An error occurred while installing pg (0.17.1), and Bundler cannot continue. Make sure that `gem install pg -v '0.17.1'` succeeds before bundling. So let's try to install the  pg gem first gem install pg It will again throw an error  :( Building native extensions.  This could take a while... ERROR:  Error installing pg: ERROR: Failed to build gem native extension.     /home/sabyasachi/.rvm/rubies/ruby-2.1.0/bin/ruby extconf.rb checking for pg_config... y

How To Install PostgreSQL on Ubuntu 12.04

Step 1: Before postgres install, we should quick perform a quick update. apt-get update Step 2: Now install Postgres using the command line.   sudo apt-get install postgresql postgresql-contrib This will install the latest version available in your Ubuntu. Step 3: Install the client   sudo apt-get install postgresql-client Step 4:  For a handy GUI for PostgreSQL install pgAdmin III.  sudo apt-get install pgadmin3 Step 5:  We need to change the PostgreSQL postgres user password; sudo -u postgres psql postgres Set a password for the "postgres" database role using the command: \password postgres Step 6: Exit from Postgres   \q That's it we are done with the installation.  

How to do rake db:seed in using neo4j gem in rails 4

Neo4j is a graph database, using neo4j gem( https://github.com/neo4jrb/neo4 j) we can easily use neo4j database in our ruby on rails application ( http://programminginrubyonrails.blogspot.in/2014/12/neo-4j-with-rails.html ). Till now neo4j gem does not support rake db tasks. You can check all the supported task by typing rake -T in your console. Now we can create our own custom rake task to seed some  data in neo4j . Step 1: Create a file under lib/tasks name it seed.rake Step 2: Put the below code in seed.rake. namespace :db do   desc 'Load the seed data from db/seeds.rb'   task :seed => :environment do     seed_file = File.join(Rails.root, 'db', 'seeds.rb')     load(seed_file) if File.exist?(seed_file)   end end That's it. now you can run rake db:seed from your terminal.. Simple :) 

Set up Neo 4j With Rails In Ubuntu

How to setup new 4j database with Rails 4. Step 1: Install Neo4j Database in ubuntu.   login as Admin  sudo -i  wget -O - http://debian.neo4j.org/neotechnology.gpg.key | apt-key add -  Add Neo4J to the Apt sources list:   echo 'deb http://debian.neo4j.org/repo stable/' > /etc/apt/sources.list.d/neo4j.list  Update the package manager:  exit as admin  apt-get update  Install Neo4J:  apt-get install neo4j  sudo /etc/init.d/neo4j-service restart Step 2: Create a new rails project.  Rails new neo4j Step 3:  Add neo4j Gem in your gem file   gem 'neo4j', github: 'andreasronge/neo4j' Step 4: Go to application.rb require File.expand_path('../boot', __FILE__) require "rails" %w(   neo4j   action_controller   action_mailer   sprockets ).each do |framework|   begin     require "#{framework}/railtie"   rescue LoadError   end end # Require the gems listed in Gemfile, including any gems # you've