XML and Ruby on Rails - PowerPoint PPT Presentation

xml and ruby on rails n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
XML and Ruby on Rails PowerPoint Presentation
Download Presentation
XML and Ruby on Rails

play fullscreen
1 / 19
XML and Ruby on Rails
75 Views
Download Presentation
dylan-robertson
Download Presentation

XML and Ruby on Rails

- - - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript

  1. XML and Ruby on Rails Jennifer Andrews LIS 531F April 25,2007

  2. Strengths of databases • Effective searching • Efficient data storage (no redundancy) • Scalable • Reliable • Good security features • Been around a long time • Part of the business structure

  3. Strengths of XML • Human readable • Open standard, not tied to a platform • Structure part of document facilitates transfer and sharing of information • Flexible • Becoming more important with increase of information sharing across businesses and applications

  4. Relational Database • Stores data in tables made up of rows and columns • Each row represents a record • Order of records irrelevant • Many tables connected by “keys” • Can express complex relationships between tables

  5. XML • Hierarchical • Harder to express complex relationships • Order of data important • Preservation of order?

  6. Ruby on Rails • Based on Ruby • Web based database applications • Basic structure built into Rails • All pieces of the application interact in standard way • Advantage? Easy and speedy development of applications • OPEN SOURCE

  7. Architecture • MVC or Model, View, Controller • Controller = conductor • Model = data handling, enforces “rules” • Views = HTML, interface for interaction with user, but only displays, never handles data

  8. Step 1 – create database and tables using SQL

  9. New material Fiber Weight Brand Color Back

  10. Table in SQL

  11. Now what? • Create an XML document • Create view or “template” saved as .rxml • One small piece of code in the controller • Point browser to that view • And …..

  12. Code to generate XML resides in template xml.instruct! :xml, :version=>"1.0" xml.channel { for m in @materials xml.material do xml.title(m.fiber) xml.description(m.weight) xml.brand(m.brand) xml.color(m.color) end end }

  13. Material Controller

  14. How does it happen? • MAGIC! • A piece ofRuby code called Builder • Takes what is after the xml. and turns it into a tag • xml.description becomes <description> • can include attibutes, too • xml.price(p.price, currency => “USD”) becomes <price currency=”USD”>50.00</price>.

  15. Real Life Application • Rails app collecting orders for books • Part of that process – collecting names, addresses • Marketing department wants names of all who bought a certain book (in XML) to feed into a another program they have.

  16. Another way • Autogenerate through command called to_xml • Dumps everything • No control over order of elements • Possible to add code so if a request comes for HTML – that is what’s returned, if the request is for XML, that is what is returned

  17. Bits and pieces • Can you use XML to input data into RonR? • Installing RonR on computer • Locomotive • 2 tutorials • Put your XML knowledge to use • Start simple, ride the rails, and be amazed