Rails

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 & 2 Groups

    Rails - Presentation Transcript

    1. Rails (1)
      • Modelling the data
      Raymond van Dongelen | NHL | www.webxy.nl
    2. MVC
      • Model-view-controller (MVC) is a software architecture that separates an application's data model, user interface, and control logic into three distinct components so that modifications to one component can be made with minimal impact to the others.
      • Seperate data from decisions from view
      • Create maintainable applications
      • Let each layer perform tasks it is best at
    3. Model
      • The data that is needed for the application
      • The data is transient (is saved between sessions)
      • Closely related to databases
    4. Controller
      • Makes important decisions
      • Controls traffic
    5. View
      • Displays information
      • Handles small events
    6. Scaffolding
      • Ruby generates standard functionality for your application, including a models, views and controllers
      • You adapt it
    7. Datamodel
      • Should prevent storing the same information twice
      • Should guard relations in the data
      • Should be able to cope with changing data structure
    8. 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
    9. Ruby naming
      • Table name plural
      • Key in a table “id”
      • Reference to another table “table_id”
    10. Relations
      • belongs_to
      • has_one
      • has_and_belongs_to_many
      • has_many
    11. Let’s rock
      • Like we never done before...
    12. ActiveRecord(1)
      • Validators:
      • validates_presence_of
      • validates_uniqueness_of
      • Relations:
      • belongs_to
      • has_one
      • has_and_belongs_to_many
      • has_many
    13. ActiveRecord(2)
      • Example:
      • class Agenda < ActiveRecord::Base
      • belongs_to :user
      • validates_presence_of :user, :message => &quot;cannot be empty&quot;
      • end
    14. ActiveRecord (3)
      • @agenda = Agenda.find(1)
      • puts (@agenda.user.name)
      • <== We are able to display the user, it is automatically fetched
    15. ActiveRecord (4)
      • Dynamic find
      • Agenda.find_all_name (“Home”)
      • User.find_all_by_email (“ [email_address] ”)
    16. ActiveRecord (5)
      • Many many powerful features
      • Read chapter 14 agile web development with Ruby on Rails
    17. Example db

    + dongelendongelen, 3 years ago

    custom

    1536 views, 2 favs, 1 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 1536
      • 1533 on SlideShare
      • 3 from embeds
    • Comments 0
    • Favorites 2
    • Downloads 0
    Most viewed embeds
    • 3 views on http://www.webxy.nl

    more

    All embeds
    • 3 views on http://www.webxy.nl

    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