Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ruby on Rails by Manik Juneja Ruby On Rails. Ruby on Rails by Manik Juneja Rails is a Web Application development framework. Based on the MVC pattern.

Similar presentations


Presentation on theme: "Ruby on Rails by Manik Juneja Ruby On Rails. Ruby on Rails by Manik Juneja Rails is a Web Application development framework. Based on the MVC pattern."— Presentation transcript:

1 Ruby on Rails by Manik Juneja Ruby On Rails

2 Ruby on Rails by Manik Juneja 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 About Rails

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

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

5 Ruby on Rails by Manik Juneja DB is relationalRuby is Object Oriented TableClass RowObject ColumnsAttributes Table Level operationsClass Methods Row Level operationsObject Methods ActiveRecord Module provides ORM in Rails. Model: Object Relational Mapping

6 Ruby on Rails by Manik Juneja ActiveRecord: Getting Started 1.Specify database access details in config/database.yml file 2.Create a subclass of ActiveRecord::Base class 3.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 )

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

8 Ruby on Rails by Manik Juneja ActiveRecord: Instance methods

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

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

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

12 Ruby on Rails by Manik Juneja 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.

13 Ruby on Rails by Manik Juneja 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/1http://mysite.com/user/show/1 File config/routes.rb, is used to map external requests to internal actions. ActionController controlleruser actionshow id1

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

15 Ruby on Rails by Manik Juneja 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.

16 Ruby on Rails by Manik Juneja 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. ActionView

17 Ruby on Rails by Manik Juneja 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 ) Layouts, Partials, Components

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

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

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

21 Ruby on Rails by Manik Juneja THANK YOU


Download ppt "Ruby on Rails by Manik Juneja Ruby On Rails. Ruby on Rails by Manik Juneja Rails is a Web Application development framework. Based on the MVC pattern."

Similar presentations


Ads by Google