UPenn on Rails pt 1

  • 875 views
Uploaded on

 

More in: Technology
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
875
On Slideshare
0
From Embeds
0
Number of Embeds
1

Actions

Shares
Downloads
7
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n
  • \n

Transcript

  • 1. UPenn on Rails Lesson 1: Data and Views
  • 2. DataViews
  • 3. Data
  • 4. class Team• name• (id, created_at, updated_at)
  • 5. class Location• name• address• (id, created_at, updated_at)
  • 6. class Game• starts_at• ends_at• location• home_team• away_team• (id, created_at, updated_at)
  • 7. class Game• starts_at• ends_at class Location• location• home_team• away_team• (id, created_at, updated_at)
  • 8. class Game• starts_at• ends_at class Location• location• home_team class Team• away_team• (id, created_at, updated_at)
  • 9. CODE!
  • 10. Database Migrations• live in db/migrate• ordered• Abstracted SQL column types• includes id and timestamps by default
  • 11. MORE CODE!
  • 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. Can also be nested• GET /locations/3/games (show games for one location)
  • 14. ‘public’ folder• For all static files• Rails looks here first• Offers caching options
  • 15. Views
  • 16. ERB• Like JSP/ASP, but in ruby• lots of helper functions for forms, etc.• layout → view → partials
  • 17. VIEW CODE!
  • 18. ActiveRecord Associations• 1 to 1 (belongs_to - has_one)• 1 to many (belongs_to - has_many)• many to many (has_many :through)
  • 19. Other points• Controllers• Next class: User stories and testing!
  • 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/