The Rails router recognizes URLs and dispatches them to a controller's action. It also generate paths and URLs. Rails router deals URLs in a different way from other language routers. It determines controller, parameters and action for the request.
The super function in Ruby is used to invoke the original method. It calls the super class implementation of the current method.
new – makes a new object but doesn't save it to the database
save – saves the model. If the model is new a record gets created in the database, otherwise the existing record gets updated.
create – makes a new object and saves it to the database in one go
Here are the benefits:
☛ it's really easy to go wrong during writing SQL queries
☛ each different type of database usually has a slightly different flavour of SQL, so it could be really painful if, during work on a big app, you decide to switch to a different database
☛ using Active Record reduces code significantly and makes it easier to read
☛ using Active Record makes common operations simpler and easier than writing your own SQL statements
Rails test is very simple to write and run for your application. As Rails script generates models and controllers, in the same way test files are also generated. Rails also uses a separate database for testing. Test database in an application is rebuilt each time the application's test run, and hence you always have a consistent database when your tests are run.
The app/controllers subdirectory holds all the controller classes for the app. Controllers handle web requests from the user. The app/helpers subdirectory holds helper classes, which are used to assist the model, view, and controller classes. By keeping helper classes in a separate subdirectory, the model, view, and controller classes can remain lean and uncluttered.
Caching is used in any web technologies. It speeds up the performance by storing previous results for subsequent requests. By default, cahcing is disabled in Rails.
Rails caching is available at three levels of granularity:
The purpose of this simple question is to make sure a developer is familiar with a test-driven development. A beginner may not have dealt with this file yet. The rakefile is similar to the makefile in Unix, and assists with packaging and testing Rails code. It's used by the rake utility, which ships natively with the Ruby installation.
RoR was generally preferred over WEBrick server at the time of writing, but it can also be run by:
Lighttpd (pronounced ‘lighty') is an open-source web server more optimized for speed-critical environments.
Abyss Web Server- is a compact web server available for windows, Mac osX and Linux operating system. Apache and nginx
Rails filters are methods that run before or after a controller's action method is executed. They are helpful when you want to ensure that a given block of code runs with whatever action method is called.
Rails support three types of filter methods:
☛ Before filters
☛ After filters
☛ Around filters