2013-11-09

Windows welcome screen slow

After I log in to Windows 7 the welcome screen stays on for ages, in the past it was almost instant.  I’ve tried various suggestions from forums and none of them worked, then it struck me what it was!

Windows was trying to reconnect network drives after I had logged in, but one of them (a connection to my iMac) was unobtainable because my iMac was off.  I disconnected the mapped network drives and speed is back to normal Smile

2013-11-04

Installing Ruby on Rails, RubyMine and MongoDB on Ubuntu Linux

Here are some really basic instructions which should work on a virgin installation of Ubuntu Linux.  I tried following some instructions in a book but they were awful, these are what I ended up with.

Install some installation helper tools etc

sudo apt-get install build-essential git-core
sudo apt-get install curl
bash -s stable < <(curl -s https://raw.github.com/wayneeseguin/rvm/master/binscripts/rvm-installer)
echo '[[ -s "/home/x/.rvm/scripts/rvm" ]] && source "/home/x/.rvm/scripts/rvm"' >> ~/.bashrc
source ~/.bashrc

Install JavaScript interpreter

sudo apt-get install nodejs

Install MongoDB server and clients

sudo apt-get install mongodb-server
sudo apt-get install mongodb-clients

Install Rails

sudo apt-get install rails

Install Ruby 1.9.3 and set it as the default version to use

rvm install 1.9.3
rvm use --default 1.9.3

Install Gems required by Ruby

gem install rails
gem install mongoid
gem install therubyracer

Java JDK for RubyMine

sudo apt-get install openjdk-7-jdk
export JAVA_HOME=/usr/lib/jvm/java-7-openjdk-amd64/bin

Now download RubyMine from http://www.jetbrains.com/ruby/download/ then extract it and move it to /opt

Start RubyMine, thereafter it will be available in the start menu

cd /opt/RubyMine-5.4.3.2.1/bin

Create a directory for Rails projects and cd into it

mkdir ~/RailsProjects
cd ~/RailsProjects

Create a new rails project without active record

rails new TestMongoDB --skip-active-record

Open the project using RubyMine and edit the GemFile contents, add the following

gem 'bson', '~> 2.0.0.rc2'
gem 'mongoid', git: 'git://github.com/mongoid/mongoid.git'

In RubyMine go to the Tools menu and select Bundler->Install to install the Ruby Gems we have just added to the project.

Create a config file in config/mongoid.yml and paste in the following

development:
  sessions:
    default:
      database: testercles
      hosts:
        - localhost

Go back to your Terminal window to create some data to retrieve

mongo
use testercles
db.Books.save( { Title : "This is the title" })

Create a Book class in app/models/book.rb

require 'rails/mongoid'
class Book
  include Mongoid::Document

  field :Title, type: String
end

In RubyMine go to the Tools menu then “Run rails generator”->Controller (or press ctrl+alt+G then type controller) – name the controller Home

Add the following require to the top of the class file and insert the following index method

require 'mongoid'

  def index
    @book = Book.all.first()
  end

Create a view for this controller/action, you can do this by clicking the icon in the gutterbar to the left of the method name, this will create the view automatically for you.  Set the view html to the following

The book title is: <%= @book.Title %>

Edit config/routes.rb and add the following root

root :to => "home#index"

Now run your app and navigate your browser to http://localhost:3000