Install Rails 3.1.3 and set up in Linux

Install RVM

If you are not already installed RVM install from here:
https://rvm.beginrescueend.com/rvm/install/

If you already have rvm installed, update it to the latest version.

$ rvm get latest
$ rvm reload
$ rvm -v

Create a Rails 3.1.3 Gemset

Create a default Rails 3.1.3 gemset. It’s advisable to create a new gemset for each application you build. But to get started, create just one new Rails 3.1.3 gemset as your default.

$ rvm ruby-1.9.2-p290@rails313 --create --default

To see a list of the gemsets you have installed:

$ rvm gemset list

And see a list of the gems included with the standard Ruby installation:

$ gem list

$ rvm list gemsets

rvm gemsets

ruby-1.9.2-p290 [ i386 ]
ruby-1.9.2-p290@global [ i386 ]
=> ruby-1.9.2-p290@rails313 [ i386 ]

Make sure you are using the newest version of Rake before you install Rails 3.1.3.

$ gem update rake
$ rake --version

Install Rails

$ gem install rails -v "3.1.3"

DETAILS:

RVM Version

rvm 1.10.1 by Wayne E. Seguin <wayneeseguin@gmail.com>, Michal Papis <mpapis@gmail.com> [https://rvm.beginrescueend.com/]

Bundler Version

builder (3.0.0)
bundler (1.0.21)

LOCAL GEMS after installed Rails 3.1.3

*** LOCAL GEMS ***

actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
arel (2.2.1)
builder (3.0.0)
bundler (1.0.21)
erubis (2.7.0)
hike (1.2.1)
i18n (0.6.0)
json (1.6.5)
mail (2.3.0)
mime-types (1.17.2)
multi_json (1.0.4)
polyglot (0.3.3)
rack (1.3.6)
rack-cache (1.1)
rack-mount (0.8.3)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
railties (3.1.3)
rake (0.9.2.2)
rdoc (3.12)
sprockets (2.0.3)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
tzinfo (0.3.31)

Unicorn Version

unicorn (4.1.1)
All Gems installed
actionmailer (3.1.3)
actionpack (3.1.3)
activemodel (3.1.3)
activerecord (3.1.3)
activeresource (3.1.3)
activesupport (3.1.3)
addressable (2.2.4)
ansi (1.4.1)
arel (2.2.1)
aws-s3 (0.6.2)
bcrypt-ruby (2.1.4)
builder (3.0.0)
bundler (1.0.21)
cocaine (0.2.1)
coffee-script (2.2.0)
coffee-script-source (1.2.0)
colorize (0.5.8)
daemons (1.1.5)
delayed_job (2.1.4)
devise (1.4.2)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.2.6)
faraday (0.6.1)
hashie (1.2.0)
hike (1.2.1)
hoe (2.12.5)
i18n (0.6.0)
jquery-rails (1.0.14)
json (1.6.5)
kaminari (0.12.4)
kgio (2.7.2)
libv8 (3.3.10.4 x86-linux)
machinist (2.0.0.beta2)
mail (2.3.0)
metaclass (0.0.1)
mime-types (1.17.2)
mocha (0.10.0)
multi_json (1.0.4)
multi_xml (0.2.2)
multipart-post (1.1.4)
mysql2 (0.3.6)
net-ldap (0.2.2)
newrelic_rpm (3.3.0)
nifty-generators (0.4.6)
nokogiri (1.4.7)
oa-basic (0.2.6)
oa-core (0.2.6)
oa-enterprise (0.2.6)
oa-more (0.2.6)
oa-oauth (0.2.6)
oa-openid (0.2.6)
oauth (0.4.5)
oauth2 (0.4.1)
omniauth (0.2.6)
orm_adapter (0.0.6)
polyglot (0.3.3)
pyu-ruby-sasl (0.0.3.3)
rack (1.3.6)
rack-cache (1.1)
rack-mount (0.8.3)
rack-openid (1.3.1)
rack-ssl (1.3.2)
rack-test (0.6.1)
rails (3.1.3)
railties (3.1.3)
raindrops (0.8.0)
rake (0.9.2.2)
rdoc (3.12)
rest-client (1.6.7)
riddle (1.5.1)
rspec (2.6.0)
rspec-core (2.6.4)
rspec-expectations (2.6.0)
rspec-mocks (2.6.0)
rspec-rails (2.6.1)
ruby-openid (2.1.8)
ruby-openid-apps-discovery (1.2.0)
rubyntlm (0.1.1)
sass (3.1.12)
sass-rails (3.1.2)
sprockets (2.0.3)
SyslogLogger (1.4.0)
therubyracer (0.9.4)
thinking-sphinx (2.0.10)
thor (0.14.6)
tilt (1.3.3)
treetop (1.4.10)
ts-delayed-delta (1.1.2)
turn (0.8.2)
tzinfo (0.3.31)
uglifier (1.0.3)
unicorn (4.1.1)
warden (1.0.6)
wkhtmltopdf (0.1.2)
xml-simple (1.1.1)

Advertisements

Twitter bootstrap typeahead difficult to add custom entries

 

If you are not familiar with twitter bootstrap typeahead please take a look at http://twitter.github.com/bootstrap/javascript.html#typeahead

While I am using twitter bootstrap, I found it is difficult to add the custom entries.

1 .When we add a entry and clicking on Enter the typeahead is taking the first list item as the value of the test box.

I solved this by Editing the typeahead javascript source code, refer my code from

https://github.com/abhilashak/Ajax-Typeahead

 

 

Two ways to load files in Rails

There are two ways that files get loaded in Rails:

It is registered in the autoload process, and you reference a constant that corresponds to the file name. For instance, if you have app/controllers/pages_controller.rb and reference PagesController, app/controllers/pages_controller.rb will automatically be loaded. This happens for a preset list of directories in the load path. This is a feature of Rails, and is not part of the normal Ruby load process.
Files are explicitly required. If a file is required, Ruby looks through the entire list of paths in your load paths, and find the first case where the file you required is in the load path. You can see the entire load path by inspecting $LOAD_PATH (an alias for $:).

Since lib is in your load path, you have two options: either name your files with the same names as the constants, so Rails will automatically pick them up when you reference the constant in question, or explicitly require the module.

I also notice that you might be confused about another thing. ApplicationController is not the root object in the system. Observe:

module MyModule
  def im_awesome
    puts "#{self} is so awesome"
  end
end
class ApplicationController < ActionController::Base
  include MyModule
end

class AnotherClass
end

AnotherClass.new.im_awesome
# NoMethodError: undefined method `im_awesome' for #

You will need to include the module into whatever class you want to use it in.

class AnotherClass
  include MyModule
end

AnotherClass.new.im_awesome
# AnotherClass is so awesome

Of course, in order to be able to include the module in the first place, you’ll need to have it available (using either of the techniques above).

Reference: This note is from a blog/site that I looked for some knowledge.

How to know your machine is 32 or 64 bit?

Here is an easy way to find this, in command line type

$ getconf LONG_BIT

Synopsis:

getconf [-v specification] system_var

the getconf utility shall write to the standard output the value of the variable specified by the system_var operand.

So it prints the value of ‘LONG_BIT’.

Read linux manual for getconf: http://linux.die.net/man/1/getconf

 

Get information about your Rails Environment

To get information about your Rails Environment Rails, Ruby, Rack versions use the following command,

$ rake about

About your application's environment
Ruby version 1.9.2 (i686-linux)
RubyGems version 1.8.10
Rack version 1.3
Rails version 3.1.3
JavaScript Runtime therubyracer (V8)
Active Record version 3.1.3
Action Pack version 3.1.3
Active Resource version 3.1.3
Action Mailer version 3.1.3
Active Support version 3.1.3
Middleware Rack::Cache, ActionDispatch::Static, Rack::Lock, Rack::Runtime, Rack::MethodOverride, Rails::Rack::Logger, ActionDispatch::ShowExceptions, ActionDispatch::RemoteIp, Rack::Sendfile, ActionDispatch::Reloader, ActionDispatch::Callbacks, ActiveRecord::ConnectionAdapters::ConnectionManagement, ActiveRecord::QueryCache, ActionDispatch::Cookies, ActionDispatch::Session::CookieStore, ActionDispatch::Flash, ActionDispatch::ParamsParser, ActionDispatch::Head, Rack::ConditionalGet, Rack::ETag, ActionDispatch::BestStandardsSupport, Warden::Manager, OmniAuth::Builder
Application root /home/abhi/my_app
Environment development
Database adapter mysql2
Database schema version 20120704103548