Showing posts with label rails. Show all posts
Showing posts with label rails. Show all posts

Monday, June 22

Recruitment Pains -1

Note: Expressed here are my personal views and experience.

All these five years I never felt that recruitment was such a pain. I am not referring to freshers but to the so called experience guys 2+. Was trying to help my friend in getting a good Ruby on Rails resource. Though this was not the first time, and I have done even at all my previous companies but I should say it's a totally, shockingly new experience.
  • I heard that in telephonic interviews people try to fool the interviewers under the wrong names or even speaking on behalf of someone else. Observed the same with one of the candidates from Karnataka, India.

  • Another great gem who claims to be working for a budding company from past 2.5 years, but the truth is he started working only couple of months back and he was trying to fool us.

  • Another beautiful one I can't even think of something like this. A guy claimed to be 1.9 yrs experience in Ruby on Rails went through the couple of rounds of interview and was not bad. So we offered him the position so irresponsible was he, didn't even respond back. So withdrew the offer.

  • One of the coolest one, which you got to hear... Another aspirant(friend of above mentioned guy) sent us the same application and claimed it to be done by him entirely.

In the whole process what I failed to understand was, why can't people be genuine to themselves. What were such candidates trying to prove?
Can they perform same way, even they were offered the job?
Why do they create wrong impressions and ultimately they will be in trouble by not performing?
...
...
...
I can list many more... but what's the use.

But I would like to stretch out and help other Ruby on Rails recruiters by sharing away their names. Hoping to save others time and money.

Friday, January 23

RoR based Social Networking apps compared

Ruby on Rails and Social networking are probably few that took limelight when WEB2.0 bug was bit! You hear/find/discuss... everywhere on these, and I thought it would be good idea to club the both and do a comparison withing social networking Applications based on Ruby on Rails.

RoR Based Social Networking Apps Compared

Thursday, April 3

ActiveRecord - CRUD operations - 2

We learn t how to create rows in the database. Moving next in CRUD, it is Reading data from db tables. Reading data involves/requires set of constraints/conditions. Something like, details of specific user, product pricing range, sorting order, matching criteria... and the list goes on. To go ahead with these operations ActiveRecord provides the following handy methods, parameter symbols to you:

find
find_by_xyz
find_by_sql

:first :all :conditions :include :order :limit :select :joins :offset :readonly :lock
etc...

Getting into details, previously we created few rows about user into users table. Now we use this find to read/retrieve the data. Little about "find", it is counterpart for "select * from users" in SQL. The syntax is very plain and simple to pick up.
Say, now I want to read/retrieve the data of all users.

User.find(:all)
so the find method connects to users table (through User class of model) and through parameter "all" it fetches info of all the users a simple array. If we use parameter :first, then only first record would be fetched.
User.find(:first)
say now I want to introduce some constraints. :conditions is the parameter to be used.
Like, I want user with a specific name
User.find(:first,
:conditions => "name='sumanth'" )

but in case the name to be matched comes dynamically through params, then there would be slight change in the above syntax. Like this,
User.find(:first,
:conditions => "name=?,params[:name] ")

or

User.find(:first,
:conditions => "name= '#{
params[:name] }'")


if you want more than one parameter to be checked/matched in the conditions then we can separate each with 'and'.

User.find(:first,
:conditions => ["name=? and email=?",params[:name] ,params[:email]])
thus we can play around with more options/parameter that "find" accommodates. Don't forget to separate each options with "," as I had used it after :first and before :conditions options.

Wednesday, April 2

ActiveRecord - CRUD operations -1

Having seen how do we handle the relationships across db tables through rails now let us dig little deeper on how to perform CRUD operations.
Create
Read
Update
Delete
Well Rails ActiveRecord does help you out with lots of keywords and many more convenient, easily understandable, meaningful commands. In nut shell, you can carryout all these sql queries without using sql syntax at all...

Inserting data - We generally use SQL Insert statements to insert/create new rows of data and Rails offers a simple way of creating new rows in tables. One of doing it is by using "new" or by "create" method.
The syntax looks very simple, as below:

Based on previous posts we can coolly observe/interpret the above code like this:
  1. As per ActiveRecord pattern in rails, this says that User is the model connecting to users table in database.
  2. All the columns (eg:name here...) of the "users" table go in do ... end loop, 'u' is the iterator.
  3. Once you set the values of each column then end with save (u.save).
Why to save?
Because, new method would only creates an object and so to store into db we need to explicitly say it to save.
Is there any alternative one?
In many instances, people create objects, define the data and they tend to forget saving the data. Active Record offers another method, create, which would instantiates the model object as well as stores it into the database.


Using both new, create methods we can either insert multiple rows of data or even the form data can be passed as parameters.

Saturday, March 1

has_and_belongs_to_many : habtm in Rails

has_and_belongs_to_many, simply "habtm" of rails would address/handle the many to many relationships of the tables.

Let us take this scenario where we have two tables, "products" belong to "categories" and "categories" belongs to "products" in more than one ways. That is each product belongs to many categories and each category contains many products. In each of the model, category and product the relation would be shown using habtm (has_and_belongs_to_many).






Closely observing the above example, we can see that the products table and categories table contains habtm relation. There is an intermediate table "categories_products", which would carry the primary key of each table.

At the database level this is achieved using an intermediate join table. The convention followed here is the name of the join table is the concatenation of the two target table names but in alphabetical order. In our example, we joined the table categories to the table products, so Active Record will look for a join table named categories_products.

Note:

  1. The join table carry the foreign keys of each table.
  2. There will be no model for this intermediate table (categories_products)

Well that precisely explains how we implement many to many relationships in Rails. That is not all there is one more way of expressing the relationship between tables, "has_through" which we will touchbase later.

Monday, January 28

Web Applications

Database is one of the key things for the web applications. The flow of web application can be simply put into the following broad steps:

  • User makes request from Browser/Client
  • The "http" request carries this to Server (web/app server)
  • The web server parts the request with the help of CGI/FCGI...
  • CGI/FCGI gives the control to application
  • Application takes the rest of game, which include
    • Identifying the actions/method
    • Actions/Methods would do the logic
    • Contacts the database
    • Fetches the data and pushes to front (with appropriate html's...)
  • The server would redirect the same to client side.
  • The user gets the content he asked for.
That would give good picture on how the web application work.
The above points give us information on what are the components that are required and each of them will be covered in the posts coming upon!

Tuesday, January 15

Ruby on Rails - Installing Rails

Recently my laptop crashed as the virus invaded to each and every folder possible. I could not open any of local folders, files and also not able to access the internet. I was so fed up, without second thought I just reformatted my system. Of course, later I realized the value of backup, when I was going through the installations.
Adding to this when I tried to install rails through "gem install rails --include-dependencies". It was annoying message, which said the request to remote server timed out!

Well I was just discussing with my juniors what exactly rails consists/made of?
Rails is nothing but Web-application framework with template engine, control-flow layer, and ORM.
I also explained that they are nothing but few ruby files called/named as gems.
activeresource, rails, activesupport, activerecord, actionpack,
I recollected that, and instead of depending on net connection speed, went to ruby forge and picked up all the above gems (latest version 2.0.2) and stored on to local folders. Then installed one by one in the order... (click the links to download)
  1. activeresource 2.0.2
  2. rails 2.0.2
  3. activesupport 2.0.2
  4. activerecord 2.0.2
  5. actionpack 2.0.2
  6. actionmailer 2.0.2
Download the archive.
Note: The order is maintained based on the dependencies the other
So this is what downloaded/installed when you run the command "gem install rails --include-dependencies".


Though each of the above listed gems could become a topic by itself, let me brief what's the role each of them got to play:
  • activeresource - Think Active Record for web resources.
  • rails - Web-application framework with template engine, control-flow layer, and ORM.
  • activesupport - Support and utility classes used by the Rails framework.
  • activerecord - Implements the ActiveRecord pattern for ORM.
  • actionpack - Web-flow and rendering framework putting the VC (Views & Controllers) in MVC
  • actionmailer - Service layer for easy email delivery and testing.
The embedded image shows the list of gems that will be installed, when you install ruby, rails.

Thanks to my friend Manoj for the screenshot.
Cross check:
  1. ruby -v => To check the version of ruby installed
  2. gem -v => To check the version of gems installed
  3. rails -v => To check the version of rails installed
  4. gemlist => To find the list of all gems installed

Monday, January 14

Ruby on Rails Hosting - Heroku!

In my last post I discussed on the way we create 'class' and the Object Oriented paradigm in general.
Let me remind all again, this course is structured to provide enough information on ruby such that it would help to take a loot on Ruby on Rails. Stressing again on the importance of Ruby on Rails, an MVC architecture based framework, a well organised, easily maintainable (no mess whatsoever!)... which all mean faster production and rest all...

I thought I would start creating some basic web applications based on ror, before that I want to bring notice to all about Hosting an application.

To host any application it requires an Application/web server, CGI/fCGI, and the environment in which you application is developed and the related databases and plug ins/vendor software (if any used!).

The good news is that you have we need not go through this entire process of install, setting up things, configuring things etc.,

Heroku :
Heroku is an online hosting environment for the rails based web applications. Not just that it come out with pretty good number of features like editing application online, export and importing the existing rails applications, customising the url's, share and collaborate online the rails projects...

Have a look at this !

Disclaimer:
Please do contact the Heroku team if you have queries on privacy and other issues.

Monday, December 10

Ruby on Rails Learning through examples

What ruby is used for?
Let us recollect the statement:
Ruby is "an interpreted scripting language for quick and easy object-oriented programming".
Ruby is used for many kind of applications be it writing automation scripts and run on your local pc's, or developing automation tools, or Website, or Blogs, Web Application or web based products and the list goes on...

We here pick up basics of Ruby just enough to get going with Rails and start developing simple websites and web applications.
All the things that we had said about ruby in earlier post What is Ruby? will be discussed in coming posts.
Learning through Examples:

Before even going for installing the ruby in your desktop, let us experiment on ruby with small examples and work/execute them here online.

This is our play ground:
This is called interactive ruby shell and we find ">>" similar to command/shell prompt. Now let's start with famous example of printing out "Hello World!" statement.
  1. type puts "Hello World!" >> puts "Hello World!"
  2. then click "Enter" button
  3. Now you would find the expected returned
  • >> puts "Hello World!"
  • Hello World!
    => nil
So puts is the ruby way of printing the things to console/prompt. The first line means to print the string within the quotes(i.e. Hello World!). Your would also find "=> nil" displayed in the next line of the Hello World! statement, puts always returns nil, which is Ruby’s absolutely-positively-nothing value.

Going on to the next example:
  • Ruby has simple syntax.
  • Ruby is dynamically typed.
  • Ruby needs no variable declarations.
  • Ruby operators are also methods.
Now I want to do simple math. Based on the above points,
to add two integers just type : 4+2
to subtract two integers just type : 4-2
to multiply two integers just type : 4*2
to divide two integers just type : 4/2
You can check out with other types also. Need not be of same type, since ruby is dynamic language at the run time they would be evaluated.
for example you type 2.0+3 and see for yourself.

Coming on to the variable declaration, ruby does not require the variable declarations. Let us the see this point also:
you type
>> a=5
=>5
>>b=2.0
=>2.0
>>c=a+b
=>7.0
As you see we have not declared the variables a,b,c and what type they hold. All these variables are evaluated at the run time and treated accordingly.
Ruby treat the operators(+,-,*,/,%...) as just like methods, which is conceptually derived from Smalltalk.

Download the pdf version of Learning Through Examples.
The pdf includes:
  • Useful links
  • Duck typing explained with example.
  • Examples with appropriate comments and explanation.
  • Ruby resources links.

Wednesday, December 5

Ruby on Rails - Course structure

You find lot of materials, websites and many articles where you get information about Ruby and Ruby on Rails.
Well, do not get over loaded with the information. If anybody is serious about learning and practicing Ruby on Rails, can make use of the below course structure. This course structure, I had just jotted down to train freshers and friends whoever interested to know more about RoR.
Note: This structure is framed based on
  1. my experience in RoR.
  2. my previous session on RoR gathering.
If anybody is interested can contact me for more information.

Download Ruby on Rails course structure in pdf

Prerequisites for the RoR Course:
The course is structured keeping in view of less experienced/freshers in the industry. So considereable time is given for all introductory topics.
However, having knowledge/experience is an added advantage:

1. Exposure to any of the programming languages (c,c++,c#,java...)/Scripting languages(perl, php, smalltalk...).

2. Overview on how web application works.

3. Understanding of the necessity of Data models, Configuration Management.

4. Necessary tools/IDE's (Eclipse IDE, notepad...)

5. Good Analyzing skills.

6. Web Technologies (HTML, JavaScript, CSS, XML, )

Download Ruby on Rails course structure in pdf

COURSE CONTENT

Introduction

· What is Ruby?

· What is it used for?

· Where do I get and install Ruby?

· Core facilities, built-in library and standard library.

· Basic concepts - object orientation, regular expressions, arrays, hashes, etc.

Basic Ruby Language Elements

· Structure of statements and comments.

· Variables and constants.

· Operators. Assignments, calculations, etc. Integer, float and string formats.

· Single and double quotes, here documents, general strings.

Control Structures

· Blocks and the if statement.

· Writing conditions.

· Comparative, boolean and range operators.

· Conditionals - if, unless, case, etc. Loops - while, for in, until, etc. break, next, retry and redo. defined? and ternary operators.

Object Orientation: Individual Objects

· History - unstructured and structured code. Introduction to object oriented programming.

· Classes and methods.

· Static and nonstatic.

· Instances, constructors and destructors.

· Accessing members of a class.

· Loading and using classes.

· Direct access to variables.

· Encouraging class use.

Classes and Objects

· Objects, classes and methods.

· Constructors and attributes.

· Instance and class variables.

· Local and global variables.

· Class and object methods.

· Including files - load and require.

Collections (Arrays and Hashes) in Ruby

· What is a collection?

· Arrays and hashes.

· Constructing an array.

· Nesting arrays. Hash keys, iterators, etc.

More Classes and Objects

· Public, private and protected visibility.

· Singletons and defs.

· Inheritance mixins, and super.

· Destructors and garbage collection.

· Namespaces and modules.

· Hooks.

· Calling methods with code blocks.

· Looking inside objects - reflection.

Strings and Regular Expressions

· Anchors, literals, character groups and counts.

· Matching in Ruby.

· Modifiers i, o, x and m.

· Pattern matching variables.

Special Variables and Pseudo-Variables

· ARGV, $0 and friends - the command line.

· Other special variables from $: through $ to Other special variables from $: through $ to Other special variables from $: through $ to Other special variables from $: through $ to $<. lt;. lt;.

· Environment variables.

· Pseudo-variables.

· Reserved words in Ruby.

Exceptions.

· begin and end (and a mention of BEGIN and END).

· Raise and rescue.

· Throw and catch.


Download Ruby on Rails course structure in pdf

Ruby on the Web

· CGI and the Ruby Apache Module.

· Using cgi.rb; URL decoding, forms, sessions, cookies, etc.

· Embedding Ruby in HTML - the <% <%= and <%# tags.

Ruby GUIs, XML, MySQL Database Connectivity

· Using Ruby/DBI to connect to MySQL, Oracle, etc.

MVC ARCHITECTURE

· What is MVC Architecture?

· Importance of it?

· How it helps?

WebApplications

· What are WebApplications?

· Essentials of WebApplications?

· SDLC (Software Development Life Cycle)

· Database Architecture

· Configuration Management (concept & tools)

· Application/Web Servers


Rails Framework

· What is Ruby on Rails?

· MVC (Model, view, controller) design principles.

· Rails structures -

o WEBrick servers,

o URLs and embedded code.

o Directory structure.

o Database connections.

· Creating the application

o the database and tables.

· First application through Scaffolds.

· Validation and customising the display.

· Adding a new controller.

· Adding viewers and layouts.

· Active Records.

· Emailing and logging from within Rails.

Ajax

· What is AJAX?

Ajax on Rails

· How to implement AJAX on Rails framework?

· What is Protoype?

· What is Scriptaculous?

· Ajax Effects.

· Rich UI experience.

· Visual Effects.


HOW TO PUT ABOVE LEARN T CONCEPTS IN TO REAL TIME PROJECTS?

Download Ruby on Rails course structure in pdf
I am open to receive any enhancement tips and open for discussion on the course structure.(tosumanthkrishna AT gmail DOT com)

Thursday, November 22

Ruby on Rails - RoR

It's been quite appreciable amount of time that I spent on Web Technologies and been involved with many web based products. I was working on RoR. Yes it's the same thing much talked topic among developers and many web gurus.
Ruby on Rails :

Why to re-invent the wheel?
I am not going to talk on
What is ruby?
What is Rails?
Because many had already done enough work on that.

Then Why this post?
Recently I had been to a talk on Ruby on Rails, attended by many people belonging to different groups like from developers to mangers. I was very much inspired by the speaker. Mr. Rajasekhar an eminent speaker, I would say he did really good job by framing up all necessary details for any fresher to start experiments on Ruby on Rails in just 3 - 4 hours of session.
I got an oppurtunity to explain and elaborate the concepts with working examples and live projects here and there between Rajashekar's session.



The session went on so well and also it was a gentle reminder for me to start sharing on RoR.

Geeks watch out this space... more to come!
More about the Session
More about the OpenSource Community