Translate

Sunday, 14 April 2013

1. Why Ruby on Rails?
Ans:
 1.CRUD (convention over configuration)
2. DRY Principal (Do not repeat Your self )
3. Gems and Plugins
4. Pure OOP Concept
5. Scaffolding
6.. Rest Support
7.Action Mailer
8. Rake support
9. open source
10.Rpsec Suppot for testing

2. What are Ruby Names
Ans: Classes, variables, methods, constants and modules

3.  Difference between Symbol and String?
Ans Strings are  Mutable , Symbols arre immutable 
Note:Mutable objects can be changed after assignment while immutable objects can only be overwritten

4. Difference between Application Server and Web Server
Ans:apache, nginx, IIS are web servers
mongrel, webrick, phusion passenger are app servers

App server is something which works with particular programming language and parses and executes the code
since mongrel and webrick can only work with rails, so they are app servers

Web servers are servers which can take the request from the browser.
Web servers normally works on port 80 though we can change the port in configuration
since mongrel and webrick can take that request directly, so they can be thought of as web servers but web servers do have a lot of other functionality like request pipeline, load balancing etc.
App servers lack these functionalities.

About Mongrel server:
mongrel work as web as well as app server if you are talking about dev environment
but in production, mongrel alone can not work it will be too slow
so we need a web server in front of mongrel


5. What is request.xhr?
Ans: A request.xhr tells the controller that the new Ajax request has come, It always return Boolean values (TRUE or FALSE)

6. What is ORM in Rails?
Ans: ORM tends for Object-Relationship-Model, it means that your Classes are mapped to table in the database, and Objects are directly mapped to the rows in the table.

7. Ruby Support Single Inheritance/Multiple Inheritance ?
Ans: Ruby Supports only Single Inheritance.
You can achieve Multiple Inheritance through MIXIN concept means you achieve using module by including it with classes.

8. What is the log that has to seen to check for an error in ruby rails?
Ans: Rails will report errors from Apache in log/apache.log and errors from the Ruby code in log/development.log. If you’re having a problem, do have a look at what these logs are saying. On Unix and Mac OS X you may run tail -f log/development.log in a separate terminal to monitor your application’s execution.

9. What is the difference between nil and false in ruby?
Ans: False is a boolean datatype, Nil is not a data type it have object_id 4

10. How is visibility of methods changed in Ruby (Encapsulation)?
Ans: By applying the access modifier : Public , Private and Protected access Modifier

11.What is agile development? What are the strenghts?
Agile software development refers to a group of software development methodologies based on iterative development, where requirements and solutions evolve through collaboration between self-organizing cross-functional teams
Advantages:
  • Customer satisfaction by rapid, continuous delivery of useful software
  • Working software is delivered frequently (weeks rather than months)
  • Projects are built around motivated individuals, who should be trusted
  • Continuous attention to technical excellence and good design
  • Simplicity
  • Self-organizing teams
  • Regular adaptation to changing circumstances

12 what is observers
Observers are similar to callbacks, but with important differences. Whereas callbacks can pollute a model with code that isn’t directly related to its purpose, observers allow you to add the same functionality outside of a model. For example, it could be argued that a User model should not include code to send registration confirmation emails. Whenever you use callbacks with code that isn’t directly related to your model, you may want to consider creating an observer instead.

13.What are filters? and how many types of filters are there in ruby?
Filters are methods that are run before, after or “around” a controller action.
Filters are inherited, so if you set a filter on ApplicationController, it will be run on every controller in your application.
Filter can take one of three forms: method reference (symbol), external class, or inline method (proc).
14.Difference between  Gem and Plugin
GEM
1. Gem is a packaged ruby application using the packaging system defined by RubyGems.
2. Rails itself is a Gem
3. We can install,upgrade and query the gem version.
4. Gem installed for Ruby interpreter can be used system-wide by that interpreter.
Plugin
1. Plugin is an extension of Rails Framework.
2. Can not be upgraded by using a command. To upgrade one have to uninstall and then install upgraded version.
3. Has to be hooked into rails application. (has to have init.rb)
4. Have an install.rb file.
5. Can only be used application wide.
15.Mixins in Ruby

When a class can inherit features from more than one parent class, the class is supposed to show multiple inheritance.

 Ruby does not suppoprt mutiple inheritance directly but Ruby Modules have another, wonderful use. At a stroke, they pretty much eliminate the need for multiple inheritance, providing a facility called a mixin.
Mixins give you a wonderfully controlled way of adding functionality to classes. However, their true power comes out when the code in the mixin starts to interact with code in the class that uses it.
Let us examine the following sample code to gain an understand of mixin:
module A
def a1
end
def a2
end
end
module B
def b1
end
def b2
end
endclass Sample
include A
include B
def s1
end
end samp=Sample.new
samp.a1
samp.a2
samp.b1
samp.b2
samp.s1
Module A consists of the methods a1 and a2. Module B consists of the methods b1 and b2. The class Sample includes both modules A and B. The class Sample can access all four methods, namely, a1, a2, b1, and b2. Therefore, you can see that the class Sample inherits from both the modules. Thus you can say the class Sample shows multiple inheritance or a mixin.
-----
what is git rebase

you can find some good stuff here
Ruby On rails question