Netbeans add ruby platform


Install RVM and Ruby version what ever you want .

Once you done with ruby installation,
From terminal type below command..

$rvm use 1.9.1
$cd /home/alan/programs/netbeans_6_8/bin ***or wherever your netbeans is installed
$./netbeans

I hope, it will help.
For details visit http://www.skorks.com/2010/01/using-multiple-rubies-seamlessly-on-the-one-machine-with-rvm/comment-page-1/#comment-3422

Cheers

 

Heroku vs Engine Yard


#1 “Ease of Use”
Heroku blows Engine Yard away. you install the gem and can deploy your application in minutes. There are also commands you can run on your local machine to get information about your application.
Engine Yard is moving forward, but it is still pretty technical. It’s really easy if you have a public github repo, but anything other than that starts to get “more complicated” quickly.

#2 “Architecture”
Engine Yard gives you a “real” virtual machine. This means you’ve actually got a single CPU virutal host that you ssh into and effectively do whatever you want.
Heroku gives you a sandbox with walls around it, and I think it’s a shared environment. It’s actually kinda difficult to figure out exactly what they’re running as you cannot log onto the machine direction.

#3 “Startup Price”
Heroku gives you a free (as in beer) environment.
Engine Yard let’s you run a trial environment for free for a period of time, but you eventually have to pay for it… even if nobody ever visits your site.

#4 “Flexibility”
Heroku lets you do anything you want as long as they’ve preconfigured it to enable you to be able to do it. 
Engine Yard gives you ssh capability to the machine, which means you can do anytChing you want even if they didn’t think it would be a good idea. 

Overall, I’d say Heroku is like taking the bus: if enough people want to go the same place at the same time, it’s more economical. Engine Yard is like buying a car: it’s going to be a bit more expensive and you’re going to need to know how to drive, but it is a much more flexible solution.

Cheers

Rails Observer


What is observer?

Observer serves as a connection point between models and some other subsystem whose functionality is used by some of other classes, such as email notification. It is loose coupling in contract with model callback.

When should we use?

If your model code gets too messy start to think about using observers for some unessential behavior. The real power (at least as I see it) of observers lies in their ability to serve as a connection point between your models and some other subsystem whose functionality is used by all (or some) of the other classes. Let’s say you decide to add an IM notification to your application – say you want to be notified about some (or all) of the CRUD actions of some (or all) of the models in your system. In this case using observers would be ideal – your notification subsystem will stay perfectly separated from your business logic and your models won’t be cluttered with behavior which is not of their business. Another good use case for observers would be an auditing subsystem.

Observer

$rails g observer EmailNotification

class EmailNotificationObserver < ActiveRecord::Observer
  observe :order, :address
 
  def after_create(model)    
      if model.class.name == “Order”
        Notifier.order_created.deliver
    else
        Notifier.address_created.deliver    
    end    
  end
end

Notifier Model:

class Notifier < ActionMailer::Base

    #layout “notifier”    
    
  default from: “test12@gmail.com”
 
  def order_created
    mail(:to => ‘mpravin@gmail.com’, :subject => “Order”) do |format|
        format.html {render :layout => ‘notifier’}        
    end
  end
 
  def address_created
    mail(:to => ‘mpravin@gmail.com‘, :subject => “Address”)    
  end
 
end

Cheers!

Amazon S3 Library for Ruby


1. Install amazon s3 gem.

$gem install aws-s3

2. Connect with S3.

require 'aws/s3'

AWS::S3::Base.establish_connection!(
  :access_key_id     => 'key goes here',
  :secret_access_key => 'secret goes here'
)

3. Various operation on S3 buckets:

a) store an object on S3
S3Object.store('me.jpg', open('headshot.jpg'), 'photos')

b) More explicitly data
S3Object.store(
  'name of object',
  File.open('large-picture.jpg'),
  'name of bucket',
  :content_type => 'image/jpeg'
)

c) Fetch object from S3
picture = S3Object.find 'headshot.jpg', 'photos'

Cheers!

 
 

 

JRuby on Rails vs. Ruby on Rails


JRuby is the ruby implementation that runs on a JVM where as Matz’s ruby is a C implementation.

Key features to note are:

-Jruby having very good performing JVM and much faster than Ruby 1.8.6 (.i.e MRI) 
-It allows us to access some very popular Java libraries from Ruby
-It supports both Ruby 1.8.6 and Ruby 1.9 language specifications 
-It has very good support for Rails today
-It has very good support for Google App Engine today 
-It can use a multitude of web server configurations both Java and non-Java 
-It has support for true multi-threading because the Global Interpreter Lock (GIL) doesn't exist
-Jruby runs on Java VM's and it's either compiled or interpreted down to Java byte code.
-JRuby can integrate with Java code. If you have java class libraries (.jar's), you can reference and use them from within ruby code with JRuby. In the other direction you can also call Jruby code from within Java. JRuby can also use the JVM and application server capabilities.
-JRuby is usually hosted within Java application servers such as Sun's glassfish or even the Tomcat web server.
-Although you cannot use native ruby gems with JRuby there are jruby implementations for most of the popular ruby libraries

Cheers!

Managing Multiple Environments for an App


Create your servers and fix your remotes

We’ll need to create both remote environments, staging and production.Since we’ll be pushing to two applications we are using the –remote argument to make two sensibly named remotes.

First create staging:
$ heroku create --remote staging

Push code to heroku:
$ git push staging master
Migrate database:
$ heroku run rake db:migrate --remote staging
Get remote inof:
$ heroku ps --remote staging
Then production:
First create production:
$ heroku create --remote production

Push code to heroku:
$ git push production master
Migrate database:
$ heroku run rake db:migrate --remote production
Get remote inof:
$ heroku ps --remote production

Linking local branches to remote apps

This pushes my local topic branch named red-bg into remote branch master on the remote repository named production.

git config remote.[remoteName].push [localBranchName]:[remoteBranchName]

$ git config remote.production.push red-bg:master

$ git push production red-bg:master -f

Also, you can do this directly with git push:

$ git push heroku +HEAD:master
$ git push -f heroku HEAD:master

That’s it 🙂


			

Rails 3: How to “redirect_to” in Ajax call?


Replaced below redirect method

redirect_to(:controller => 'jobs', :action => 'index')

with this:

render :js => "window.location = '/jobs/index'"

and it works fine!

Else

Pass static url to link

= link_to ‘Set as application form’, “org_form_and_documents?id=#{params[:id]}”, :onclick => “set_as_app()”, :class => “active”

function set_as_app()
  {
      var IDs = [];
      $(“.form_check”).each(function()
      {
        var each_id = ‘#’+this.id;        
        if ($(each_id).attr(‘checked’))
        {            
            IDs.push(this.id);
            $.ajax({
                 url: “/organizations/change_form”,
                 data: { form_id: this.id, org_id: $(‘#org’).val(), season: $(‘#season’).val()},
                 cache: false,                      
            })
        }                  
      });
      
  }
I hope, it will help..!!!

 

 

 

Every thing with git


1. Track status of modified file.

pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git status -s
M app/assets/stylesheets/scaffolds.css.scss

2.Track difference in file.

pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git diff
diff –git a/app/views/orders/index.html.erb b/app/views/orders/index.html.erb
index d2c3f03..9b9bd01 100644
— a/app/views/orders/index.html.erb
+++ b/app/views/orders/index.html.erb
@@ -26,4 +26,4 @@

<h2>nothing</h2>

-<h1>nothing</h1>
+<h1>pravinmishra88@gmail.com</h1>

3.Shows abbreviated commits and a nice graph of branches with the messages on a single line.

pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git config –global alias.lol “log –pretty=oneline –abbrev-commit –graph –decorate”
pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git lol
*   84cdcd1 (HEAD, master) Merge branch ‘blue’
|\
| * f534661 (blue) yellow
* |   2d06b84 Merge branch ’email’
|\ \
| |/
|/|
| * 520585c (email) change email
* | 85a0703 blue background
|/
* b0f4f06 (rspec-test) few changes
* 1ff053a (origin/master) first commit

4. Stage the changes. In order to begin tracking a new file, you use the command git add.

git add (file)

5. Review your changes. The main tool you use to determine which files are in which state is the git
status command.

git status/diff

6.Stage and commit

git commit -a

7. Get a Reference(The ref in the URL must be formatted as heads/branch, not just branch. )

pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ find .git/refs
.git/refs
.git/refs/tags
.git/refs/heads
.git/refs/heads/email
.git/refs/heads/blue
.git/refs/heads/master
.git/refs/heads/rspec-test
.git/refs/remotes
.git/refs/remotes/origin
.git/refs/remotes/origin/master

8.Ignoring Files

Often, you’ll have a class of files that you don’t want Git to automatically
add or even show you as being untracked. These are generally automatically
generated files such as log files or files produced by your build system. In such
cases, you can create a file listing patterns to match them named .gitignore.

$ cat .gitignore
*.[oa]
*~

9.Remove file
To remove a file from Git, you have to remove it from your tracked files (more
accurately, remove it from your staging area) and then commit. The git rm
command does that and also removes the file from your working directory so
you don’t see it as an untracked file next time around.
$ git rm file_name

10. Moving file

If you want to rename a file in Git, you can run something like
$ git mv file_from file_to

11. Viewing the commit history

-See all commit by date and user

$ git log

-options is -p, which shows the diff introduced in each commit.
$ git log -p -2
Merge: 2d06b84 f534661
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:41 2012 +0530

Merge branch ‘blue’

commit f5346619e66f9e59ed6141ba46ec7bd899d82de0
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:05 2012 +0530

yellow

diff –git a/app/assets/stylesheets/scaffolds.css.scss b/app/assets/stylesheets/scaffolds.css.scss
index 99d7183..8a4b162 100644
— a/app/assets/stylesheets/scaffolds.css.scss
+++ b/app/assets/stylesheets/scaffolds.css.scss
@@ -1,5 +1,5 @@
body {
–  background-color: blue;
+  background-color: yellow;
color: #333;
font-family: verdana, arial, helvetica, sans-serif;
font-size: 13px;

-if you want to see some abbreviated stats for each commit, you can use the –stat option:
$ git log –stat
commit 84cdcd11c41c66897ec8327615028742071ae1f8
Merge: 2d06b84 f534661
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:41 2012 +0530

Merge branch ‘blue’

commit f5346619e66f9e59ed6141ba46ec7bd899d82de0
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:05 2012 +0530

yellow

app/assets/stylesheets/scaffolds.css.scss |    2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

commit 2d06b8425bcb28592835ce1133f500e243770cb6
Merge: 85a0703 520585c
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:43:54 2012 +0530

Merge branch ’email’

-This option changes the log output to formats other than the default.
$ git log –pretty=oneline
84cdcd11c41c66897ec8327615028742071ae1f8 Merge branch ‘blue’
f5346619e66f9e59ed6141ba46ec7bd899d82de0 yellow
2d06b8425bcb28592835ce1133f500e243770cb6 Merge branch ’email’
520585c934bad43db8a390333c103c552a393f9e change email
85a070328bff3bf5835f7b27389899a00b817102 blue background
b0f4f06fae59165f0f797b5e056d259726b3d455 few changes
1ff053a7037e907af4a60cfdd34eca29da75f6f3 first commit

-This option adds a nice little ASCII graph showing your branch and merge history, which we can see our copy of the Grit project repository:
$ git log –pretty=format:”%h %s” –graph
*   84cdcd1 Merge branch ‘blue’
|\
| * f534661 yellow
* |   2d06b84 Merge branch ’email’
|\ \
| |/
|/|
| * 520585c change email
* | 85a0703 blue background
|/
* b0f4f06 few changes
* 1ff053a first commit

12.Limit log output

We can time-limiting options such as –since and –until are very useful.
$ git log –since=2.weeks
commit 84cdcd11c41c66897ec8327615028742071ae1f8
Merge: 2d06b84 f534661
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:41 2012 +0530

Merge branch ‘blue’

commit f5346619e66f9e59ed6141ba46ec7bd899d82de0
Author: Pravin  Mishra <diatm.pravin.it.07.27@gmail.com>
Date:   Thu Sep 6 23:48:05 2012 +0530

12. Undoing Things

-One of the common undos takes place when you commit too early and possibly forget to add some files, or you mess up your commit message. If you want to try that commit again, you can run commit with the –amend option:

$ git commit –amend

Unstaging a Staged File
$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
#
# Changes not staged for commit:
#   (use “git add <file>…” to update what will be committed)
#   (use “git checkout — <file>…” to discard changes in working directory)
#
#    modified:   README.rdoc
#    modified:   Rakefile
#
no changes added to commit (use “git add” and/or “git commit -a”)
pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git add .
pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
#
# Changes to be committed:
#   (use “git reset HEAD <file>…” to unstage)
#
#    modified:   README.rdoc
#    modified:   Rakefile
#
pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git reset HEAD Rakefile
Unstaged changes after reset:
M    Rakefile
pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ git status
# On branch master
# Your branch is ahead of ‘origin/master’ by 1 commit.
#
# Changes to be committed:
#   (use “git reset HEAD <file>…” to unstage)
#
#    modified:   README.rdoc
#
# Changes not staged for commit:
#   (use “git add <file>…” to update what will be committed)
#   (use “git checkout — <file>…” to discard changes in working directory)
#
#    modified:   Rakefile

4oo. Tree of git files

pravinmishra@ubuntu:~/workSpace/every_thing_with_git$ tree -a
.
├── app
│   ├── assets
│   │   ├── images
│   │   │   └── rails.png
│   │   ├── javascripts
│   │   │   ├── application.js
│   │   │   └── orders.js.coffee
│   │   └── stylesheets
│   │       ├── application.css
│   │       ├── orders.css.scss
│   │       └── scaffolds.css.scss
│   ├── controllers
│   │   ├── application_controller.rb
│   │   └── orders_controller.rb
│   ├── helpers
│   │   ├── application_helper.rb
│   │   └── orders_helper.rb
│   ├── mailers
│   │   └── .gitkeep
│   ├── models
│   │   ├── .gitkeep
│   │   └── order.rb
│   └── views
│       ├── layouts
│       │   └── application.html.erb
│       └── orders
│           ├── edit.html.erb
│           ├── _form.html.erb
│           ├── index.html.erb
│           ├── new.html.erb
│           └── show.html.erb
├── config
│   ├── application.rb
│   ├── boot.rb
│   ├── database.yml
│   ├── environment.rb
│   ├── environments
│   │   ├── development.rb
│   │   ├── production.rb
│   │   └── test.rb
│   ├── initializers
│   │   ├── backtrace_silencers.rb
│   │   ├── inflections.rb
│   │   ├── mime_types.rb
│   │   ├── secret_token.rb
│   │   ├── session_store.rb
│   │   └── wrap_parameters.rb
│   ├── locales
│   │   └── en.yml
│   └── routes.rb
├── config.ru
├── db
│   ├── migrate
│   │   └── 20120731003213_create_orders.rb
│   ├── schema.rb
│   └── seeds.rb
├── doc
│   └── README_FOR_APP
├── Gemfile
├── Gemfile.lock
├── .git
│   ├── branches
│   ├── COMMIT_EDITMSG
│   ├── COMMIT_EDITMSGtest
│   ├── COMMIT_EDITMSGtestt
│   ├── COMMIT_EDITMSGtesttM-A
│   ├── config
│   ├── description
│   ├── HEAD
│   ├── hooks
│   │   ├── applypatch-msg.sample
│   │   ├── commit-msg.sample
│   │   ├── post-update.sample
│   │   ├── pre-applypatch.sample
│   │   ├── pre-commit.sample
│   │   ├── prepare-commit-msg.sample
│   │   ├── pre-rebase.sample
│   │   └── update.sample
│   ├── index
│   ├── info
│   │   └── exclude
│   ├── logs
│   │   ├── HEAD
│   │   └── refs
│   │       ├── heads
│   │       │   ├── blue
│   │       │   ├── email
│   │       │   ├── master
│   │       │   └── rspec-test
│   │       └── remotes
│   │           └── origin
│   │               └── master
│   ├── objects
│   │   ├── 00
│   │   │   └── 7ce9c43328f559333b67ab5661248fd3555aff
│   │   ├── 01
│   │   │   └── a7a5fc116da111c0bc377b87972824ac5a5d5a
│   │   ├── 02
│   │   │   └── 5d1b1f1862d54aad0677bb80baec240fc27db7
│   │   ├── 05
│   │   │   ├── 188f08ed67cd28c1540da208992d57bc50f5d2
│   │   │   └── f4b2c6730253dd0533e426aad35d9551aa49bf
│   │   ├── 08
│   │   │   └── 5187fa58b1631e955f5d514d895a7721466797
│   │   ├── 0d
│   │   │   └── d897d9f57ced84d38e2776d21bf3fba6cb30d6
│   │   ├── 0f
│   │   │   └── bf4a10a9e4e258a83e6857411bc1a87ab5534e
│   │   ├── 12
│   │   │   └── e53b5cfb7713b7886a2e6de22b37be63cb1828
│   │   ├── 15
│   │   │   ├── 438849134f3078999b496a312773c88cecd84e
│   │   │   ├── 4705c6aa1c8ead8c99c7915373e3c44012057f
│   │   │   ├── 93355496d89e475ab4cd45808a7001dc6bd933
│   │   │   └── b8ed1348be35f46103e9a0cd10fec2b4919930
│   │   ├── 17
│   │   │   └── 9c14ca52c384fc27f42fa76ea982c4674b3c20
│   │   ├── 19
│   │   │   └── cb1c637acfd6f8ab180aaf1b0b45b610cbf006
│   │   ├── 1f
│   │   │   ├── 3bebad2659e088ac0c926c18511666b3c8b4b8
│   │   │   └── f053a7037e907af4a60cfdd34eca29da75f6f3
│   │   ├── 20
│   │   │   └── 4e9b656452b48c9dd9226255fdf17bd84d5ca1
│   │   ├── 21
│   │   │   └── 1748af0c417e6a03c6cb6f76d35e7d46d7d1f4
│   │   ├── 22
│   │   │   └── 68ce8216edd04b11b2e969997d799ed36bf90e
│   │   ├── 24
│   │   │   └── 20abe3038342909597705c910ffb8dfc6bd38b
│   │   ├── 27
│   │   │   └── abbf6392125b7c185f341d05b9369fde8ea5aa
│   │   ├── 28
│   │   │   └── c4a60cb62d6a5ef24ec8da1433d456fc5996e5
│   │   ├── 2b
│   │   │   └── 82d8b75e96d533432d9f11ee85462c1fd42393
│   │   ├── 2c
│   │   │   └── 56fa20dfed26d706d0e42e1fedcd310465f2d6
│   │   ├── 2d
│   │   │   ├── 06b8425bcb28592835ce1133f500e243770cb6
│   │   │   └── efd72e4d0a58b91b25f17f9d09315378b9d11d
│   │   ├── 30
│   │   │   └── 8bd499ed787a5661f7d537430c46884bad2a64
│   │   ├── 31
│   │   │   └── 92ec897bb6021141b0d304b724886d0907c0db
│   │   ├── 32
│   │   │   └── bbc36b8f5793223ef2c67308d344250fbdeb01
│   │   ├── 35
│   │   │   └── 37cfa635ef6d89fd8f5b51423ff364e79321c6
│   │   ├── 3b
│   │   │   └── 0428a94ef40b42809434e8b8fd289cd84b5b56
│   │   ├── 3c
│   │   │   └── 8f3fa4a33a630600099cce22c4bad1f420b89b
│   │   ├── 3f
│   │   │   ├── 5ddd8378f7b1bd43edf3bdbf6d8c923878f85c
│   │   │   ├── 91c121c8803e43a570061c7c43229602937458
│   │   │   └── ea27b91670e04c83a15269790a44b41b7d9ce1
│   │   ├── 42
│   │   │   ├── f6f6014f3d56aa9a43686c5de88c1860f9b715
│   │   │   └── fa3b2ead43317131e51b1e179c0eb58b319f82
│   │   ├── 43
│   │   │   └── d29f4f52246e7203a60c102c390c11ad55f474
│   │   ├── 44
│   │   │   ├── 3227fd481070889635a8205fb8ee06148fa209
│   │   │   ├── 89e58688ca642d8e0e9489f6896f49f9b89da6
│   │   │   └── 9b797391bd561d7aeb4adf870b6bddafe469b2
│   │   ├── 45
│   │   │   └── 774453e52bc437ff39123d471007b860095e86
│   │   ├── 46
│   │   │   └── 8d484a61f2d000ee5951262b9a1d51bf32a102
│   │   ├── 47
│   │   │   ├── c0f123aa7cd47e0f7169585a6d560aefabc65e
│   │   │   └── ddd6d409e52291d937d65a40ab88e7af3053f2
│   │   ├── 48
│   │   │   └── 6da35de91d3892e489f691c37bf25255addca3
│   │   ├── 49
│   │   │   ├── 30a6b713cd0c6f40160a427ef3f7581fcbbd3f
│   │   │   └── d4560b3981a89676c58e26550fded2ad5e9685
│   │   ├── 4a
│   │   │   ├── c1b3d98e3a170c44a846ddaf6d46721586d29c
│   │   │   └── ed04aba9a88a2cce4a3270fed3056e3ede6f43
│   │   ├── 4b
│   │   │   └── 66d04a4f062834cec2c55805291fed724b98f6
│   │   ├── 4e
│   │   │   ├── 10bf15eb422c2f87467cd41bc4875152918845
│   │   │   └── db1e857ee6c203463c7fa0387aae32496ec93d
│   │   ├── 50
│   │   │   └── 9ea6b2a89e29512b4fd0c92c1c4466dc18e8f8
│   │   ├── 52
│   │   │   ├── 0585c934bad43db8a390333c103c552a393f9e
│   │   │   └── dacae1997b7b0b90706a51b91860b114cc1a04
│   │   ├── 53
│   │   │   └── 091f8d943728655c2de5e283c5e2041f35d500
│   │   ├── 59
│   │   │   └── 385cdf379bd06a8d2326dcd4de6d5cd5d3f5b0
│   │   ├── 5a
│   │   │   └── 67a145b11f852d9e45e34afca9c5e5b03c2ea3
│   │   ├── 5b
│   │   │   └── 3cf596fc4c3779536f5b9c29cb49af36938fe5
│   │   ├── 5c
│   │   │   └── 302a4dd4b189d391fe0b0a59faacbc6aa62123
│   │   ├── 5d
│   │   │   └── 8d9be237b28d4ebdad9cec9510764ab88154e6
│   │   ├── 67
│   │   │   └── 0521830734291afbea54a6cad7bc1d5cc62e80
│   │   ├── 72
│   │   │   ├── a250e46f5ec97389f062760951692adb720e49
│   │   │   └── aca7e441e1855f8c7a7ac1f1cbe5d42cd1235b
│   │   ├── 75
│   │   │   └── 3d544d7891331263a1e4ca047cab572b839565
│   │   ├── 76
│   │   │   └── 1567942fc20b22ba68ce6b5f46652cf63c48c0
│   │   ├── 77
│   │   │   └── 3f006428ea5ea0ac1101ab7e1f5914eda247a8
│   │   ├── 7c
│   │   │   └── 36f2356ecd12c70a4bfcde0ff671e560daf460
│   │   ├── 7f
│   │   │   └── be8dcb97d0e801b6ec9fc4278d7c420a797cc5
│   │   ├── 83
│   │   │   ├── 660ab1878ba9adc6477ed910333e32bb6b46ce
│   │   │   └── 813df06fda0023b88014318c01f788ea17406f
│   │   ├── 84
│   │   │   └── cdcd11c41c66897ec8327615028742071ae1f8
│   │   ├── 85
│   │   │   └── a070328bff3bf5835f7b27389899a00b817102
│   │   ├── 88
│   │   │   └── bef2ca81958faed1a6f5d006d14f26a1242ead
│   │   ├── 8a
│   │   │   └── 4b162bdb9f2d82d0dc38316444af0cefa5164e
│   │   ├── 8b
│   │   │   └── f1192ffec252a4562218bdf299891a319b9cb9
│   │   ├── 90
│   │   │   └── 97d830e2c27e4b1dd291b1e3ee72149251cca1
│   │   ├── 93
│   │   │   └── 30726268264424cda78f32f874bae8f61c24f8
│   │   ├── 97
│   │   │   └── 939a10a5523838c7f3ca1a3dd6bfb5b3406328
│   │   ├── 99
│   │   │   ├── 9df20181e5571fb6a74259eead0899b7ad18a1
│   │   │   └── d71831621c0f06529c39b21105a8402080310b
│   │   ├── 9a
│   │   │   ├── 48320a5f1c025b6cc9819ab539a6d17fcbaf81
│   │   │   └── 6d84a35b2adc97e67f9bdcc8eb7f17f49b48d9
│   │   ├── 9b
│   │   │   └── 9bd01b00b30ab6ee52b3e86a16ce1cf844808d
│   │   ├── 9e
│   │   │   └── 2aeb8f9431726fb731bca2159a644e30e811fb
│   │   ├── 9f
│   │   │   └── 1580f4e69b030b59fceed046480856dd209df1
│   │   ├── ac
│   │   │   └── 2e8ba6a1b189557429b5ae2f59731e101728fb
│   │   ├── b0
│   │   │   ├── 7ade6c63bc0f43b5f33acda4822a4ff37361ea
│   │   │   └── f4f06fae59165f0f797b5e056d259726b3d455
│   │   ├── b4
│   │   │   └── 0d2b59d1e32e5056ba427b9b3fd0644630f683
│   │   ├── b5
│   │   │   └── 91a352dc8adfcbc781dfbcaed4d5489b3d0175
│   │   ├── bd
│   │   │   └── 5ae3fecb4feaf0f865888edc9759d5c3d36232
│   │   ├── c2
│   │   │   └── e811817ee56b7c4f80a98a0e29215af57c2a3a
│   │   ├── c4
│   │   │   └── f14ff630a65048705dd1848a773aec6e98e321
│   │   ├── cb
│   │   │   └── deac2798cb5fde79016e7ee7961331aa4f7c7b
│   │   ├── ce
│   │   │   └── 506525fe3467ef70cf1485a2793300622534d6
│   │   ├── d2
│   │   │   └── c3f035da1c14b4efead05e6f9db416a290fde2
│   │   ├── d5
│   │   │   ├── 64d0bc3dd917926892c55e3706cc116d5b165e
│   │   │   └── edc04e65f555e3ba4dcdaad39dc352e75b575e
│   │   ├── d9
│   │   │   └── 2e427847e01b1a6f07b19e25e7b0668efaec69
│   │   ├── dd
│   │   │   ├── 05fa5b40902c631ed1a82d379e7054f88e59ad
│   │   │   └── fbd7c203be41f36d2ac1404857500f1f865b2e
│   │   ├── de
│   │   │   └── 6be7945c6a59798eb0ace177df38b05e98c2f0
│   │   ├── e1
│   │   │   └── 06f5eb4da1651e7a2e3d01d65eab298f9b38e4
│   │   ├── e3
│   │   │   └── ed01cb6b9dc73ab83658f50f17770af0b6db2a
│   │   ├── e6
│   │   │   └── 9de29bb2d1d6434b8b29ae775ad8c2e48c5391
│   │   ├── e8
│   │   │   └── 065d9505d7ec6f727021c827de18a0a95737de
│   │   ├── ea
│   │   │   └── 3ba0e03a6b78f2a812f1dccbf99ea2a1ddabbc
│   │   ├── eb
│   │   │   └── 3489a986bd8af22f03119e8989e9d10a4999d4
│   │   ├── ed
│   │   │   ├── 7931e3f168c9831579326b56de3f3c68f3b5da
│   │   │   └── ae7ef0915f4b60dd173a268a92ce766009152c
│   │   ├── f3
│   │   │   └── 648a0dbc9f021131677c88383f1cc9b15ea22e
│   │   ├── f5
│   │   │   ├── 346619e66f9e59ed6141ba46ec7bd899d82de0
│   │   │   └── 491c2323e75b9df95eb3c8f5a1cd064bc35a8b
│   │   ├── f7
│   │   │   ├── 6cb1d43f2a6ea96e48e95cf70d3a8704dd5072
│   │   │   └── bd8f6a14841f95d2840ab870dddb1132c730b2
│   │   ├── f8
│   │   │   └── da2cffd4de029d658fe2f7b9ec88f28dc34a9a
│   │   ├── fc
│   │   │   └── 6ef9282895a78dafdb3ebe9a982db6a9f1e0a0
│   │   ├── fd
│   │   │   └── e0ce2e205f9f0f055727dc7b6c5df08e362b6a
│   │   ├── fe
│   │   │   └── 41f5cc24d667635c46a533fd09bf7bb514e032
│   │   ├── info
│   │   └── pack
│   ├── ORIG_HEAD
│   └── refs
│       ├── heads
│       │   ├── blue
│       │   ├── email
│       │   ├── master
│       │   └── rspec-test
│       ├── remotes
│       │   └── origin
│       │       └── master
│       └── tags
├── .gitignore
├── lib
│   ├── assets
│   │   └── .gitkeep
│   └── tasks
│       └── .gitkeep
├── log
│   ├── development.log
│   └── .gitkeep
├── public
│   ├── 404.html
│   ├── 422.html
│   ├── 500.html
│   ├── favicon.ico
│   └── robots.txt
├── Rakefile
├── README.rdoc
├── script
│   └── rails
├── test
│   ├── fixtures
│   │   ├── .gitkeep
│   │   └── orders.yml
│   ├── functional
│   │   ├── .gitkeep
│   │   └── orders_controller_test.rb
│   ├── integration
│   │   └── .gitkeep
│   ├── performance
│   │   └── browsing_test.rb
│   ├── test_helper.rb
│   └── unit
│       ├── .gitkeep
│       ├── helpers
│       │   └── orders_helper_test.rb
│       └── order_test.rb
├── tmp
│   ├── cache
│   │   ├── assets
│   │   │   ├── C58
│   │   │   │   └── E30
│   │   │   │       └── sprockets%2F4e829185f1504944b41c494529b66bb4
│   │   │   ├── CB5
│   │   │   │   └── 9E0
│   │   │   │       └── sprockets%2Fe459168835a5f27b832ace20874f7c10
│   │   │   ├── CC2
│   │   │   │   └── 5A0
│   │   │   │       └── sprockets%2F2630585056a1db4f59b004c2aa5122cd
│   │   │   ├── CD7
│   │   │   │   └── 6F0
│   │   │   │       └── sprockets%2Fbd3936370d0f952ada5774e2230046ed
│   │   │   ├── CD8
│   │   │   │   └── 370
│   │   │   │       └── sprockets%2F357970feca3ac29060c1e3861e2c0953
│   │   │   ├── CF0
│   │   │   │   └── DA0
│   │   │   │       └── sprockets%2Fd7d5b37686831d37c4dd75e645f5e016
│   │   │   ├── CF4
│   │   │   │   └── CE0
│   │   │   │       └── sprockets%2Fda5971a6f6cc7e9923f28850c46625b8
│   │   │   ├── D1F
│   │   │   │   └── D30
│   │   │   │       └── sprockets%2F6c9f4608bd916f573fafb413927d4d09
│   │   │   ├── D20
│   │   │   │   └── BA0
│   │   │   │       └── sprockets%2Fe8d306af79db99713a3334ea95957d2c
│   │   │   ├── D32
│   │   │   │   └── A10
│   │   │   │       └── sprockets%2F13fe41fee1fe35b49d145bcc06610705
│   │   │   ├── D33
│   │   │   │   └── E20
│   │   │   │       └── sprockets%2F25e6a0c3cf070477edaae503564f426c
│   │   │   ├── D4E
│   │   │   │   └── 1B0
│   │   │   │       └── sprockets%2Ff7cbd26ba1d28d48de824f0e94586655
│   │   │   ├── D5A
│   │   │   │   └── EA0
│   │   │   │       └── sprockets%2Fd771ace226fc8215a3572e0aa35bb0d6
│   │   │   ├── D7E
│   │   │   │   └── 510
│   │   │   │       └── sprockets%2Fe5289c1e989b8dd6656cd939e0ac0ac0
│   │   │   ├── D82
│   │   │   │   └── 350
│   │   │   │       └── sprockets%2F4cfa19f9bca26dc87fd9550127f4759e
│   │   │   ├── DDC
│   │   │   │   └── 400
│   │   │   │       └── sprockets%2Fcffd775d018f68ce5dba1ee0d951a994
│   │   │   ├── DED
│   │   │   │   └── F70
│   │   │   │       └── sprockets%2F7ed83d0c16cbc2b202b4c65baeec647c
│   │   │   ├── E04
│   │   │   │   └── 890
│   │   │   │       └── sprockets%2F2f5173deea6c795b8fdde723bb4b63af
│   │   │   ├── E0F
│   │   │   │   └── F70
│   │   │   │       └── sprockets%2F96eea36d34f8fef13ff7a1d0576d8eae
│   │   │   ├── E19
│   │   │   │   └── 2A0
│   │   │   │       └── sprockets%2F10fcfbe6ebae11a40c8eac41939a1b9a
│   │   │   └── E25
│   │   │       └── 4C0
│   │   │           └── sprockets%2Fde2fd9fd11c04a582cdbbe3d84a35ae6
│   │   └── sass
│   │       └── 7d2ae8fecd82f6692540c213575bf838322da99d
│   │           ├── orders.css.scssc
│   │           └── scaffolds.css.scssc
│   ├── pids
│   │   └── server.pid
│   ├── sessions
│   └── sockets
└── vendor
├── assets
│   ├── javascripts
│   │   └── .gitkeep
│   └── stylesheets
│       └── .gitkeep
└── plugins
└── .gitkeep

200 directories, 242 files

logger


What is logger?

  • Rails makes use of ruby’s standard logger, Log4r, or another logger that provides a similar interface can also be substituted if you wish.
  • A logger object is made available to each of ActiveRecord, ActiveController and ActiveMailer.

How to write logger?

  • logger.info "Starting process fubar..."

Log level?

  • IThe available log levels are: :debug, :info, :warn, :error, :fatal. The ruby Logger class normally also accepts :any, but that doesn’t seem to work with rails.
  • config.log_level = :debug

Log path?

  • The log file path is relative to the RAILS_ROOT directory. Make sure that the file exists and has permissions that allow writing for the user that rails will run under.
  • config.log_path = 'log/debug.log'

Initialize logger in ruby app?

  • ActiveRecord::Base.logger = Logger.new(STDERR)
  • ActiveRecord::Base.logger = Logger.new(File.open(‘log/database.log’, ‘a’))

Example?

begin
  RAILS_DEFAULT_LOGGER = Logger.new(“#{RAILS_ROOT}/log/#{RAILS_ENV}.log”)
rescue StandardError
  RAILS_DEFAULT_LOGGER = Logger.new(STDERR)
  RAILS_DEFAULT_LOGGER.level = Logger::WARN
  RAILS_DEFAULT_LOGGER.warn(
    “Rails Error: Unable to access log file. Please ensure that log/#{RAILS_ENV}.log exists and 
is chmod 0666. " +
    "The log level has been raised to WARN and the output directed to STDERR until the problem 
is fixed.”
  )
end

Q Is it possible to display the logs in the console rather than using the “debug.log” file?
-cd /railsapp/log
-tail -f development.log