Do you know JRuby?


When I was amidst picking up ROR, I came across JRuby today, while there was a huge debate among techies and Pros in the project I work, whether JRuby is best (or) Ruby, in terms of Scalability, maintainability, Performance Read more

Learning ROR: Part 7 - Ruby Gems Explained


Until I work with ROR, my basic understanding of Gems were, it is a round shaped Chocolate released by Cadbury confectionery company, which comes in different colors. But Once I encountered ROR, it was something which bugged me on Read more

Learning ROR: Part 6 - Useful Cheatsheets


I always love to take print-outs of Cheat-Sheets (or) Quick Reference Docs and clip it to my board. When you learn ruby (or) rails, these Cheat-Sheets would be of great help in remembering the most commonly used syntax and Read more

Learning ROR: Part 5 - Rails Project Directory Structure


In our previous post, we created a new Project and Rails created the directories on our behalf. Before we move further, I would recommend Beginners to look into an awesome info-graphic which I recently came across, this helps us Read more

Do you know JRuby?

Ruby on Rails Voice your views   , ,

When I was amidst picking up ROR, I came across JRuby today, while there was a huge debate among techies and Pros in the project I work, whether JRuby is best (or) Ruby, in terms of Scalability, maintainability, Performance and Security. Hence I was interested to also dip my toe into JRuby and to know more on it.

Note: We should never compare JRuby and Ruby as it would not be the right thing, JRuby is yet another implementation of Ruby Programming Language. It differs out only in the point of Deployment,Scalability, Maintainability and Performance stand-point. 

In this blog post, I will summarize the various points found defending ROR and JROR:

Ruby on Rails

1. Ruby is a programming language.

2. Ruby runs within a native C based interpreter.

3. Deployed in nginx environment, Passenger + Nginx or Apache

4. Ruby can use native extensions

5. Ruby has some issues with userspace threading, locking

JRuby On Rails

1. JRuby is an ruby implementation written in Java.

2. JRuby runs on the Java VM (the interpreter was written in Java)

3. Deployed in Java Web Server

4. JRuby can access to Java types, objects etc.

5. JRuby has Java threads (meaning it will scale to many cpus, cores etc.)

Further Reading (Videos):

1. Ruby Platform Options Throwdown | MRI, Rubinius and JRuby

2. RailsConf 2011: Dr. Nic Williams, “Ruby Through the Ages (or, A Brief History of Ruby)”


Learning ROR: Part 7 – Ruby Gems Explained

Ruby on Rails Voice your views   , ,

Until I work with ROR, my basic understanding of Gems were, it is a round shaped Chocolate released by Cadbury confectionery company, which comes in different colors. But Once I encountered ROR, it was something which bugged me on my initial days of learning. What is Ruby Gems, What is Gemfile, What is Source, What is Gemfile.lock, Why we run “bundle install”? So many doubts. For those who encounter a similar situation like me, or needs a brush up, this blog post would be a handy guide,

What is a Gem?

A gem is a packaged Ruby application or library. It has a name (e.g. rake) and a version (e.g. 0.4.16). Gems are managed on your computer using the gem command. You can install, remove, and query (amoung other things) gem packages using the gem command. RubyGems is the name of the project that developed the gem packaging system and the gem command

What is Gemfile and Why we use it?

It holds all the dependencies the projects needs to run smoothly.

What all a GemFile contains?

The following makes the GemFile,

1. Source of the RubyGems Server,

Source:rubygems

The above line is the always the first line of a GemFile, We need to specify the URL (or) source of the RubyGems server from where various gems required by the project are fetched.

2. Gems and their Versions needed by our Program

We specify all the required Gems along with their versions as mentioned below,


group :assets do
gem 'sass-rails', '3.2.4'
gem 'coffee-rails', '~> 3.2.2'
gem 'uglifier', '>= 1.2.3'
end

So in the above statements, we have mentioned that we need “sass-rails” gems which is of version 3.2.4, and did you observe “~>” and “=>” for coffee-rails and uglifer, Let us look into what are those,

Those Operations are used as Version Constraints,

= Equals version
!= Not equal to version
> Greater than version
< Less than version
>= Greater than or equal to
<= Less than or equal to
~> Approximately greater than

The reason we prefix this to the version numbers is to inform the bundler to install the gem in the specified version range. So you may end up with a question as to where to use “~> ” and “=>”. We use “~>” for gems which undergoes regular minor releases and  “=>” which has a timed stable major release.If no version constraint operator is specified, RubyGems will assume that “=” was intended.

3. Gem Grouping

We group gems so that we can tell bundler easily which set of gems to exclude (or) to include. Basically in Rails, the grouping of gems is done with respect to Environments. the three common environments are Development, Testing, Production. Here is the sample snip below we have included “sqlite3″ gem within development group,

group :development do
  gem 'sqlite3', '1.3.5'
end

What is GemFile.lock?

When the bundler installs all the Gems in our system looking from the GemFile, it creates a quick snapshot and writes the versions installed to Gemfile.lock. This way bundler doesn’t have to recalculate all the gem dependencies each time you deploy

What is Bundler?

Bundler is a program for managing gem dependencies in your Ruby projects. With Bundler you can specify which gems your program needs, what versions they should be at, it can help you install them, load them at runtime and distribute them with your software. Basically, it takes all of the guesswork out of installing the gems needed to run your Ruby projects.

Further Reading:

To know more on these, refer the following topics,

1. Some of the Problems the Bundler Solves

2. Bundler Site

3. What is Bundler?

4. GemFile

5. Optimistic Version Constraint & Pessimistic Version Constraints

It would be great, if  you add your suggestions and help links in the comment section below.


Learning ROR: Part 6 – Useful Cheatsheets

Ruby on Rails Voice your views  

I always love to take print-outs of Cheat-Sheets (or) Quick Reference Docs and clip it to my board. When you learn ruby (or) rails, these Cheat-Sheets would be of great help in remembering the most commonly used syntax and TODO’s.

Here in this blog post,you can find some of the useful reference sheets,

1. Ruby Cheat-Sheet 1

2. Ruby Cheat-Sheet 2

3. Ruby On rails Cheat-Sheet -1 

4. Ruby On Rails Cheat-Sheet-2

5. REST Cheat-Sheet

If you find any useful Rails resources, do share them in the comment section.

Note: Cheat-Sheet will be getting older as new versions get released, So If you find any obsolete data,  would suggest you to ignore them and follow the new once. Also most of the topics in the cheat-Sheets would be fundamentals and would hardly undergo changes.


Learning ROR: Part 5 – Rails Project Directory Structure

Ruby on Rails Voice your views   ,

In our previous post, we created a new Project and Rails created the directories on our behalf. Before we move further, I would recommend Beginners to look into an awesome info-graphic which I recently came across, this helps us to understand the different folders used in Rails Project,

Note: A minor correction in the below info-graphic. the CSS, images and Javascript files in Public directory are moved into “assets” folder within “app” directory.

Added to the above Info-graphic, I am also listing the various project directories (from Micheal Hartl RailsTutorial) and their uses below,

File/Directory Purpose
app/ Core application (app) code, including models, views, controllers, and helpers
app/assets Applications assets such as cascading style sheets (CSS), JavaScript files, and images
config/ Application configuration
db/ Database files
doc/ Documentation for the application
lib/ Library modules
lib/assets Library assets such as cascading style sheets (CSS), JavaScript files, and images
log/ Application log files
public/ Data accessible to the public (e.g., web browsers), such as error pages
script/rails A script for generating code, opening console sessions, or starting a local server
test/ Application tests
tmp/ Temporary files
vendor/ Third-party code such as plugins and gems
vendor/assets Third-party assets such as cascading style sheets (CSS), JavaScript files, and images
README.rdoc A brief description of the application
Rakefile Utility tasks available via the rake command
Gemfile Gem requirements for this app
Gemfile.lock A list of gems used to ensure that all copies of the app use the same gem versions
config.ru A configuration file for Rack middleware
.gitignore Patterns for files that should be ignored by Git


1 2 3 4 5 ... 21 22   Next »