Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ruby on Rails by Manik Juneja

Similar presentations


Presentation on theme: "Ruby on Rails by Manik Juneja"— Presentation transcript:

1 Ruby on Rails by Manik Juneja

2 Ruby on Rails by Manik Juneja
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 Ruby on Rails by Manik Juneja
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 Ruby on Rails by Manik Juneja
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
DB is relational Ruby is Object Oriented Table Class Row Object Columns Attributes Table Level operations Class Methods Row Level operations Object Methods 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 Ruby on Rails by Manik Juneja
ActionController Controller orchestrates the application Receives external input Processes internal action Responds to user Receives external input In the form of a url like File config/routes.rb, is used to map external requests to internal actions. controller user action show id 1 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 Ruby on Rails by Manik Juneja
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 Ruby on Rails by Manik Juneja
Pagination Rails has inbuilt pagination support at both controller and view level Ruby on Rails by Manik Juneja

19 Ruby on Rails by Manik Juneja
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 Ruby on Rails by Manik Juneja
THANK YOU Ruby on Rails by Manik Juneja


Download ppt "Ruby on Rails by Manik Juneja"

Similar presentations


Ads by Google