Ruby On Rails Interview Questions Part-2
2.1 Top-Ten Reasons To Like Rails
1. It gives agility to web development. 2. developer can create web pages with neat effects, just like the cool kids do. 3. LEt developer focus on creating the application, not feeding the framework. 4. Applications stay maintainable as they grow. 5. Manager can say “Yes” to clients more often. 6. Testing is built in (and easy) so it gets used. 7. IImmediate feedback: edit the code, hit refresh, and the change is in my browser. 8. Meta-programming means I can program at a really high level. 9. Code generators let me get started quickly. 10. No XML!
2.2 What is is Agile Web Development with Rails?
Agile development favors • Individuals and interactions over processes and tools • Working software over comprehensive documentation • Customer collaboration over contract negotiation • Responding to change over following a plan
2.3 What is a Model ?
The model is responsible for maintaining the state of the application. model Sometimes this state is transient, lasting for just a couple of interactions with the user. Sometimes the state is permanent, and will be stored outside the application, often in a database. A model is more than just data; it enforces all the business rules that apply to that data.
2.4 What is a View?
The view is responsible for generating a user interface, normally based viewon data in the model.
2.5 What are Controllers?
Controllers orchestrate the application. Controllers receive incoming events Controllers(normally user input), interact with the model, and display an appropriate view to the user.
2.6 Explain the process from request to response in rails MVC?
IN Rails application, incoming requests are first sent to a router, which works out where in the application the request should be sent, and how the request itself should be parsed. Ultimately, this phase identifies a particular method (called an action in Rails parlance) somewhere in the action controller code. The action might look at data in the request itself, it might interact with the model, and it might cause other actions to be invoked. Eventually the action prepares information for the view which renders something to the user.
2.7 Object/Relational Mapping?
ORM libraries map database tables to classes. If a database has a table called orders our program will have a class named Order. Rows in this table correspond to objects of the class—a particular order is represented as an object of class Order. Within that object, attributes are used to get and set the individual columns. Our Order object has methods to get and set the amount, the sales tax, and so on.
2.8 What is Active Record ?
Active Record is the ORM layer supplied with Rails. It closely follows the standard ORM model: tables map to classes, rows to objects, and columns to object attributes.
2.9 What is script directory ?
The scripts directory holds programs that are useful for developers. Run any of these scripts with no arguments to get usage information.
Get performance benchmarks on one or more methods in your application.
A client that lets you interact with running Rails applications. Wetalk about this starting on page 189.
Allows you to use irb to interact with your Rails application methods. irb
Removes autogenerated files created by generate.
A code generator. Out of the box, it will create controllers, mailers,models, scaffolds, and web services
Creates a runtime-profile summary of a chunk of code from your application.
Executes a method in your application outside the context of the web. You could use this to invoke cache expiry methods from a cron job, or handle incoming e-mail.
A WEBrick-based server that will run your application.