Datamodel in Ruby

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    2 Favorites & 1 Group

    Datamodel in Ruby - Presentation Transcript

    1. Building your app (1)
      • Modeling the data
      Raymond van Dongelen | NHL | www.webxy.nl
    2. Datamodel
      • Should prevent storing the same information twice
      • Should guard relations in the data
      • Should be able to cope with changing data structure
    3. Contents
      • Datamodel
      • ActiveRecord
      • Sample application
    4. Ruby and data
      • All database handling is done in the model
      • Powerful features to validate data, guard relations, search data.
      • All data is wrapped in Ruby classes
      • SQL is almost never needed
    5. Ruby naming
      • Table name plural
      • Key in a table “id”
      • Reference to another table “table_id”
    6. ActiveRecord(1)
      • Validators:
      • validates_presence_of
      • validates_uniqueness_of
      • Relations:
      • belongs_to
      • has_one
      • has_and_belongs_to_many
      • has_many
    7. ActiveRecord(2)
      • Example:
      • class Agenda < ActiveRecord::Base
      • belongs_to :user
      • validates_presence_of :user, :message => &quot;cannot be empty&quot;
      • end
    8. ActiveRecord (3)
      • @agenda = Agenda.find(1)
      • puts (@agenda.user.name)
      • <== We are able to display the user, it is automatically fetched
    9. ActiveRecord (4)
      • Dynamic find
      • Agenda.find_all_name (“Home”)
      • User.find_all_by_email (“ [email_address] ”)
    10. ActiveRecord (5)
      • Many many powerful features
      • Read chapter 14 agile web development with Ruby on Rails
    11. Sample application User Project Task Subtask User can be in many projects Project can have many users A project has many tasks A task has many subtasks Sample can be found on http://www.webxy.nl/?p=63

    + dongelendongelen, 4 years ago

    custom

    1991 views, 2 favs, 3 embeds more stats

    A short presentation followed by a demo (not includ more

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1991
      • 1972 on SlideShare
      • 19 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 0
    Most viewed embeds
    • 12 views on http://rubisobrerieles.blogspot.com
    • 4 views on http://www.webxy.nl
    • 3 views on http://www.planetacodigo.com

    more

    All embeds
    • 12 views on http://rubisobrerieles.blogspot.com
    • 4 views on http://www.webxy.nl
    • 3 views on http://www.planetacodigo.com

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Groups / Events