0
UPenn on Rails  Lesson 1: Data and Views
DataViews
Data
class Team• name• (id, created_at, updated_at)
class Location• name• address• (id, created_at, updated_at)
class Game• starts_at• ends_at• location• home_team• away_team• (id, created_at, updated_at)
class Game• starts_at• ends_at                  class Location• location• home_team• away_team• (id, created_at, updated_at)
class Game• starts_at• ends_at                  class Location• location• home_team                       class Team• away...
CODE!
Database Migrations• live in db/migrate• ordered• Abstracted SQL column types• includes id and timestamps by default
MORE CODE!
RESTful Routes• GET /locations (show all locations)• GET /locations/3 (show one location)• POST /locations (make a locatio...
Can also be nested• GET /locations/3/games (show games for  one location)
‘public’ folder• For all static files• Rails looks here first• Offers caching options
Views
ERB• Like JSP/ASP, but in ruby• lots of helper functions for forms, etc.• layout → view → partials
VIEW CODE!
ActiveRecord        Associations• 1 to 1 (belongs_to - has_one)• 1 to many (belongs_to - has_many)• many to many (has_many...
Other points• Controllers• Next class: User stories and testing!
Homework• Make a Player scaffold• Show the players for a given team on that  team’s page• (bonus) assign players on the te...
Upcoming SlideShare
Loading in...5
×

UPenn on Rails pt 1

966

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
966
On Slideshare
0
From Embeds
0
Number of Embeds
1
Actions
Shares
0
Downloads
8
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • Transcript of "UPenn on Rails pt 1"

    1. 1. UPenn on Rails Lesson 1: Data and Views
    2. 2. DataViews
    3. 3. Data
    4. 4. class Team• name• (id, created_at, updated_at)
    5. 5. class Location• name• address• (id, created_at, updated_at)
    6. 6. class Game• starts_at• ends_at• location• home_team• away_team• (id, created_at, updated_at)
    7. 7. class Game• starts_at• ends_at class Location• location• home_team• away_team• (id, created_at, updated_at)
    8. 8. class Game• starts_at• ends_at class Location• location• home_team class Team• away_team• (id, created_at, updated_at)
    9. 9. CODE!
    10. 10. Database Migrations• live in db/migrate• ordered• Abstracted SQL column types• includes id and timestamps by default
    11. 11. MORE CODE!
    12. 12. RESTful Routes• GET /locations (show all locations)• GET /locations/3 (show one location)• POST /locations (make a location)• PUT /locations/3 (update one location)
    13. 13. Can also be nested• GET /locations/3/games (show games for one location)
    14. 14. ‘public’ folder• For all static files• Rails looks here first• Offers caching options
    15. 15. Views
    16. 16. ERB• Like JSP/ASP, but in ruby• lots of helper functions for forms, etc.• layout → view → partials
    17. 17. VIEW CODE!
    18. 18. ActiveRecord Associations• 1 to 1 (belongs_to - has_one)• 1 to many (belongs_to - has_many)• many to many (has_many :through)
    19. 19. Other points• Controllers• Next class: User stories and testing!
    20. 20. Homework• Make a Player scaffold• Show the players for a given team on that team’s page• (bonus) assign players on the team edit page• Help at http://railsforzombies.org/
    1. A particular slide catching your eye?

      Clipping is a handy way to collect important slides you want to go back to later.

    ×