Sunday 29 June 2014

Rails useful resources

  Rails: Things you must know about TDD and BDD    
  http://blog.andolasoft.com/2014/06/rails-things-you-must-know-about-tdd-and-bdd.html   
  
  ROR development-resources :    
  http://www.developerslane.com/14-top-ruby-on-rails-development-resources/#prettyPhoto   
  
  Useful blog for Rails developer:   
  http://blog.hashdog.com/articles/  
  http://robots.thoughtbot.com/  
  
  Steps to add ‘Elasticsearch’ to Rails App :   
  http://blog.andolasoft.com/2014/05/steps-to-add-elasticsearch-to-rails-app.html   
  
  Top 5 Tools for Project Management:   
  http://www.sitepoint.com/top-5-tools-for-project-management/    
  
  Sidekiq gem  
  http://sumanranjanpanda.wordpress.com/2013/09/24/steps-to-implement-sidekiq-with-rails-3-x/  
  http://tsamni.com/post/84515089035/sidekiq-performing-background-or-delayed-jobs-with  
  
  git rollback after git push  
  http://stackoverflow.com/questions/1270514/undoing-a-git-push  
  
  git structure  
  http://stackoverflow.com/questions/3666953/showing-git-branch-structure  
  
  Installing xapian-full 1.2.3 on UBUNTU  
  sudo apt-get update  
  sudo apt-get install build-essential zlib1g-dev uuid-dev  
  gem fetch xapian-full  
  gem unpack xapian-full-1.2.3.gem  
  sudo apt-get install curl  
  cd xapian-full-1.2.3  
  curl -O https://github.com/rlane/xapian-full/pull/4.patch  
  patch < 4.patch  
  gem build xapian-full.gemspec  
  gem install ./xapian-full-1.2.3.gem  
  sudo gem install xapian-full  
  cd ..  
  rm -rf xapian-full-1.2.3  
  rm xapian-full-1.2.3.gem  
  http://www.xpertpcnet.com/wordpress/2013/04/26/installing-xapian-full-1-2-3-on-ubuntu/  
 
 
  kill rails server:   
  netstat -plntu | grep 3000  
  tcp    000.0.0.0:30000.0.0.0:*        LISTEN   7656/ruby  
  The last column shows the PID and the process name, then you only need to do:  
  kill -9  7656  
  and rails s to get it working again...  
  
  or  
  Remove that file: C:/Rails/tmp/pids/server.pid  
  
  or  
    start the server on different port  
  C:\Rails>rails s -p 3001  
 
  Basic rails console commands:  
 >> User.new # Creates a new user object  
 >>  
  user = User.new(:name => “Michael Hartl”, :email =>   
 “mhartl@example.com”) => # >> user.save # Save the object   
 specified  
 >> user.name # access a specific property of the object  
 >> User.create(:name => “A Nother”, :email => “another@example.org”) # same as a user.New and a user.save  
 >> foo.destroy # destroy a created object, but the created object will still in memory (see below)  
 >> foo => # #Still gave you something even after destroy  
 >> User.find(1) # Find user with id 1  
 >> User.find_by_email(“mhartl@example.com”) # Find user by email (or any other specific attributes)  
 >> User.first # Find the first user in DB  
 >> User.all # Returns all usrs  
 >> user.email = “mhartl@example.net” #Updating a user’s property, and then do user.save  
 >>  
  user.update_attributes(:name => “The Dude”, :email =>   
 “dude@abides.org”) #Update several attr at once, and also performs a   
 user.save at the end, only attributes indicated on the object as   
 attr_accessible can be updated this way  
 >> user.errors.full_messages # If there were errors when saving the data, they will be contained here  
 If you want to access some of your helper methods while in the console:  
 >include ActionView::Helpers::TextHelper // Now you can use them  
 User.find_by_login("praaveenranganathan@gmail.com").user_company_info  
 SELECT * FROM `user_company_infos` WHERE (`user_company_infos`.`user_id` = '38f35826-2050-11e3-a135-0015e9bbd3cc') LIMIT 1;  
 http://pragtob.github.io/rails-beginner-cheatsheet/#rails-commands  
 rvm installation not working:  
  if u get RVM is not a function error
 You need to run the follow  
 source ~/.rvm/scripts/rvm  
 then run this  
 type rvm | head -n 1  
 and if you get  
 rvm is a function  
 the problem is solved.  
 You also need to run user$ rvm requirements to see dependency requirements for your operating system  
 Source: https://rvm.io/rvm/install/  
 I forget mention that you need to put this code into you ~/.bashrc or ~/.zshrc file and you will not need to write this code again.