Building Web Apps with Rails
Hello
What about you?
The Course
Hello Ruby!Hello Rails
Try Ruby!   Http://tryruby.org   Stop when you see "summary 4" or stuffabout file operations. Skip to challenge on        ...
Ruby, Ruby, Ruby●   Everything is an object●   Chain methods to your hearts content●    Bang! Or no bang?●   Hashes and :s...
A Ruby Class
Our app: FirstFM
FirstFM     Users   StationLists   Stations
FirstFM     Users   StationLists   Stations
Lets get goingrails new firstfmrails generate scaffold Station name:stringdescription:text url:stringcd firstfmrake db:mig...
What? How did this happen?
Rails has generated●    Application defaults, files and settings●    A model to represent the Station entity●    A databas...
Rails has generated●    Application defaults, files and settings●    A model to represent the Station entity              ...
Rails has generated●    Application defaults, files and settings●    A model to represent the Station entity●    A databas...
Rails has generated●    Application defaults, files and settings●    A model to represent the Station entity●    A databas...
EVERYONE ISENTITLED TO MY    OPINION
EVERYONE IS      ConventionENTITLED over TO MY     Configuration    OPINION
EVERYONE IS        Convention           overENTITLED TO MY       Configuration    (Not loved by all...)    OPINION
rake db:migrate        How does it work?In your app directory, navigate to:            db/migrate/
The Station Migration
The Station Model
The Stations Controller
CRUD actions in the controller●    Create – new, create●   Read – index, show●   Update – edit, update●    Destroy - destroy
The Show Action (Controller)  # GET /stations/1  # GET /stations/1.json  def show    @station = Station.find(params[:id]) ...
The Show Action (View)           Action / View name convention
RoR 101: Session 1
RoR 101: Session 1
RoR 101: Session 1
Upcoming SlideShare
Loading in …5
×

RoR 101: Session 1

934 views

Published on

Part 1 of 6

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

No Downloads
Views
Total views
934
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
13
Comments
0
Likes
2
Embeds 0
No embeds

No notes for slide

RoR 101: Session 1

  1. 1. Building Web Apps with Rails
  2. 2. Hello
  3. 3. What about you?
  4. 4. The Course
  5. 5. Hello Ruby!Hello Rails
  6. 6. Try Ruby! Http://tryruby.org Stop when you see "summary 4" or stuffabout file operations. Skip to challenge on Classes.
  7. 7. Ruby, Ruby, Ruby● Everything is an object● Chain methods to your hearts content● Bang! Or no bang?● Hashes and :symbols● Key value pairs :key => value● Blocks { } / do end● @instance variables
  8. 8. A Ruby Class
  9. 9. Our app: FirstFM
  10. 10. FirstFM Users StationLists Stations
  11. 11. FirstFM Users StationLists Stations
  12. 12. Lets get goingrails new firstfmrails generate scaffold Station name:stringdescription:text url:stringcd firstfmrake db:migraterails server
  13. 13. What? How did this happen?
  14. 14. Rails has generated● Application defaults, files and settings● A model to represent the Station entity● A database table to store stations● A controller to respond to requests● Views to show them
  15. 15. Rails has generated● Application defaults, files and settings● A model to represent the Station entity rails new firstfm● A database table to store stations● A controller to respond to requests● Views to show them
  16. 16. Rails has generated● Application defaults, files and settings● A model to represent the Station entity● A database table to store stations● A controller to respond to requests● Views to show them rails generate scaffold Station name:string description:text url:string
  17. 17. Rails has generated● Application defaults, files and settings● A model to represent the Station entity● A database table to store stations● A controller to respond to requests● Views to show them rake db:migrate
  18. 18. EVERYONE ISENTITLED TO MY OPINION
  19. 19. EVERYONE IS ConventionENTITLED over TO MY Configuration OPINION
  20. 20. EVERYONE IS Convention overENTITLED TO MY Configuration (Not loved by all...) OPINION
  21. 21. rake db:migrate How does it work?In your app directory, navigate to: db/migrate/
  22. 22. The Station Migration
  23. 23. The Station Model
  24. 24. The Stations Controller
  25. 25. CRUD actions in the controller● Create – new, create● Read – index, show● Update – edit, update● Destroy - destroy
  26. 26. The Show Action (Controller) # GET /stations/1 # GET /stations/1.json def show @station = Station.find(params[:id]) respond_to do |format| format.html # show.html.erb format.json { render json: @station } end end
  27. 27. The Show Action (View) Action / View name convention

×