A Blink Into The Rails Magic

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

    Favorites, Groups & Events

    A Blink Into The Rails Magic - Presentation Transcript

    1. A blink into the “rails magic”
      The meta-programming in Rails / Rails as a code generator
    2. Some rights reserved
      Nikos Dimitrakopoulos, 2009
      http://blog.nikosd.com
    3. The “classic” rails ingredients
      MVC
      DRY
      COC

    4. Not for today…
      MVC
      DRY
      COC

    5. Rails as a code generator
    6. PART I : 100% Static
    7. The directory structure
    8. Models + Tests
    9. Controllers / views + tests
    10. Resources (the whole set)
    11. Even with *implemented* views & controllers (a.k.a. “scaffolds”)
    12. Static(*) API
    13. Nothing special so far…
    14. PART II : 100% On-the-fly
    15. This is where the actual fun begins!
    16. Some basic stuff: ORM
    17. How does Rails map the attributes???
    18. The truth is in the source…
    19. A blink into the “magic”
    20. if we haven’t already generated the “dynamic” methods
    21. if we haven’t already generated the “dynamic” methods
      • generate them
    22. if we haven’t already generated the “dynamic” methods
      • generate them
      • try to call the method with the given name again!
    23. for each column on the db table :
    24. for each column on the db table :
      • define a “read” method
    25. for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
    26. for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
    27. for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
    28. for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
      • define a “question” method
    29. for each column on the db table :
      • define a “read” method
      (for example the Guest#name)
      • define a “write” method
      (for example the Guest#name = …)
      • define a “question” method
      (for example the Guest#name?)
    30. PART III : Magic happens Everywhere
    31. On the routes / Controllers
    32. + 3 more by default
    33. + 3 more by default
      More info on “resources” :
      http://api.rubyonrails.org/classes/ActionController/Resources.html
    34. On the ORM / Models
    35. Dynamic finders
    36. Dynamic finders
    37. As said this is just a “blink”
    38. Look for more in :
      • ActiveRecordassociations
      • ActiveRecordnamed_scopes
      • ActionControllerroutes
      • ActionControllerrendering
      • ActionControllerformat
      • etc…
    39. What do we get from this?
    40. What do we get from this?
      • Glue code
    41. What do we get from this?
      • Glue code
      • Domain-aware code
    42. What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
    43. What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
      • Every time
    44. What do we get from this?
      • Glue code
      • Domain-aware code
      • Out of the box
      • Every time
      • On every app
    45. Compare it with Java or .Net “enterprise” solutions…
    46. Compare it with Java or .Net “enterprise” solutions…
      © Rubyrags.com
    47. Implement your own!!!
    48. Implement your own!!!
      (Jim will give you a hint tomorrow at the Ruby Meetup)
    49. Thanks for your time
    50. Thanks for your time
      And welcome
      to themagic world of
      Rubyand Ruby on Rails
    SlideShare Zeitgeist 2009

    + demisonedemisone Nominate

    custom

    139 views, 0 favs, 0 embeds more stats

    My presentation at Athens Digital Week '09

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 139
      • 139 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 2
    Most viewed embeds

    more

    All embeds

    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