Environment variable


On Ubuntu machine


(This command will print ALL environment variables.)

$printenv USER

$echo $USER

(This will show value for environment variable USER )

$printenv | grep RUBY

(This will show only those environment variable that contain RUBY. We have used grep command for this.)

$export EDITOR=atom

(This will set environment variable EDITOR which did not exist before.)

How to get route information for your Rails app - Lessons Learned 3

We can get the route information in 2 ways.

1. From the terminal, run following command from the project home folder.

$rake routes

2. Form the browser, go to path rails/info/routes


Reading from the browser is convenient if you are developing on Windows machine and grep command is not available.


What is the difference between render and redirect? - Lesson learned 2

-Redirect is a method that is used to issue the error message in case the page is not found or it issues a 302 to the browser. Whereas, render is a method used to create the content.

-Redirect is used to tell the browser to issue a new request. Whereas, render only works in case the controller is being set up properly with the variables that needs to be rendered.

-Redirect is used when the user needs to redirect its response to some other page or URL. Whereas, render method renders a page and generate a code of 200.