1 / 21

Ruby On Rails

Ruby On Rails. About Rails. Rails is a Web Application development framework. Based on the MVC pattern Gives a pure Ruby development environment Created by DHH of 37signals. Is open source

hunter
Download Presentation

Ruby On Rails

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Ruby On Rails Ruby on Rails by Manik Juneja

  2. About Rails • Rails is a Web Application development framework. • Based on the MVC pattern • Gives a pure Ruby development environment • Created by DHH of 37signals. • Is open source • Some sites running on RoR are basecamp, tadalist, writeboard, Campfire, 43things, odeo, Blinksale, Bubbleshare, Calendarhub, Nativetext, Numsum, Sproutit, Suprglu • Some open source applications built on RoR are typo, hieraki2 Ruby on Rails by Manik Juneja

  3. Rail’s Philosophy DRY( Don’t Repeat Yourself) Every piece of knowledge should be expressed in just one place Convention over configuration Sensible defaults for just about every aspect of your application. If you need to overwrite the convention Rails makes that easy too. • The MVC architecture Ruby on Rails by Manik Juneja

  4. What is a Model? • Model stores the state of the application • Sometime this state is • Transient (Session) • Permanent (database) • Model = data + business rules that apply to it. Ruby on Rails by Manik Juneja

  5. Model: Object Relational Mapping ActiveRecord Module provides ORM in Rails. Ruby on Rails by Manik Juneja

  6. ActiveRecord: Getting Started • Specify database access details in config/database.yml file • Create a subclass of ActiveRecord::Base class • Give it a name. (By default, Active Record assumes that the name of the table is the plural form of the name of the class. By default id is the primary key ) Ruby on Rails by Manik Juneja

  7. ActiveRecord: Class methods Class Methods ( = Table level operations) Ruby on Rails by Manik Juneja

  8. ActiveRecord: Instance methods Ruby on Rails by Manik Juneja

  9. ActiveRecord Relationships: one to many Ruby on Rails by Manik Juneja

  10. ActiveRecord Relationships: many to many Ruby on Rails by Manik Juneja

  11. ActiveRecord: Other Features • Transaction Handling • Acts as (list, tree) • Aggregation • Validation • Callback • etc Ruby on Rails by Manik Juneja

  12. ActionPack : where the action happens Action Pack lies at the heart of Rails applications. It consists of two Ruby modules, ActionController and ActionView. Together, they provide support for processing incoming requests and generating outgoing responses. Ruby on Rails by Manik Juneja

  13. ActionController • Controller orchestrates the application • Receives external input • Processes internal action • Responds to user Receives external input In the form of a url like http://mysite.com/user/show/1 File config/routes.rb, is used to map external requests to internal actions. Ruby on Rails by Manik Juneja

  14. ActionController: action • Controller looks for a public instance method with the same name as the incoming action • Controller has access to the execution environment via objects such as request, params, response, cookies, session, header Ruby on Rails by Manik Juneja

  15. ActionController : filter • Filters enable wrapping of controllers’ actions — you can write a chunk of code once and have called before or after any number of actions in your controller • This is very useful in authentication, logging etc. Ruby on Rails by Manik Juneja

  16. ActionView The ActionView module encapsulates the functionality needed to render templates. A Template is text embedded with ruby code ( in erb tags <% ….. %> All instance variables of the controller are available in the template. Ruby on Rails by Manik Juneja

  17. Layouts, Partials, Components • Honoring DRY Many pages share the same header, footer, sidebar (use layouts) Multiple pages may contain same snippet of rendered HTML (use partials) Same functionality may appear on multiple pages ( use components ) Ruby on Rails by Manik Juneja

  18. Pagination Rails has inbuilt pagination support at both controller and view level Ruby on Rails by Manik Juneja

  19. Ajax on Rails • Rails has inbuilt support for Ajax • It has prototype, effects, drag drop and control JavaScript libraries built in. • JavaScriptHelper module which wrap JavaScript access in ruby code. Ruby on Rails by Manik Juneja

  20. Must Mention, before I Thank You • Action Mailer • Action Web Service • Testing Framework • Rake Ruby on Rails by Manik Juneja

  21. THANK YOU Ruby on Rails by Manik Juneja

More Related