Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Ruby on the web (ruby@uniovi workshop)

Ruby on the web (ruby@uniovi workshop)

Slides

Day 2 slides from ruby@uniovi, a 2-day workshop which was held in the University of Oviedo (Spain), from 4th to 6th March 2015.

During day 2 students enjoyed a hands-on lab oriented towards web development. Sample app and assignments are freely available at https://github.com/ruby-uniovi/jukebox-sinatra

All workshop materials are available at https://github.com/ruby-uniovi

F2e789a950f2ad80fe791ae3f5430b14?s=128

Daniel Carral

March 06, 2015
Tweet

More Decks by Daniel Carral

Other Decks in Programming

Transcript

  1. Ruby on the web Ruby: from 0 to 100 in

    14400 seconds (2) ruby@uniovi: Introducing the Ruby programming language School of Computer Sciences University of Oviedo March 2015
  2. Git

  3. git clone REPO_URL # make changes… git status git commit

    -am “Commit message” git push
  4. cd /vagrant/projects/jukebox-sinatra git pull #updates repo state git checkout workshop

    #switches branch Let’s type!
  5. git config --global user.email "a@b.com" git config --global user.name "user

    random"
  6. TIP: Use it in your thesis always ;) https://education.github.com

  7. Tests

  8. “Code without tests is bad code. ” - Michael C.

    Feathers Working Effectively with Legacy Code
  9. Unit Tests Integration Tests Acceptance Tests Smoke / Mutation /

    Stress TDD / BDD
  10. TIP: Use it in your thesis always ;) http://betterspecs.org/

  11. Web Dev

  12. None
  13. None
  14. None
  15. Blocks

  16. some_method do |param| param * 2 end

  17. Sinatra

  18. Time to code! Exercise #0 Hello, world! @ Sinatra https://trello.com/b/ziGtcloe/day-2-user-stories

  19. None
  20. ERB

  21. <ul> <% @artists.each do |artist| %> <li><%= artist.name %></li> <%

    end %> </ul>
  22. html = “<ul>” @artists.each do |artist| html << “<li>” html

    << artist.name html << “</li>” end html << “</ul>”
  23. get “/” do erb :”home/show” end

  24. None
  25. None
  26. None
  27. Persistence

  28. None
  29. class Artist include Mongoid::Document field :name, :type => String embeds_many

    :songs end
  30. > a = Artist.create(:name => “Billy Strayhorn”) #=> #<Artist …

    name: “Billy Strayhorn”>
  31. > Artist.where(:name => “Duke Ellington”).first #=> #<Artist … name: “Duke

    Ellington”>
  32. post “/artist” do artist = Artist.create(params) redirect “/artists” end

  33. None
  34. Heroku

  35. None
  36. $ heroku login $ heroku create $ bin/set_mongolab_in_heroku $ git

    push heroku workshop:master $ heroku logs -t
  37. & Rails?

  38. To learn more...

  39. None
  40. https://github.com/ruby-uniovi

  41. Happy hacking! :-) Tw: @pablorc @varezhh @dg_suarez @dcarral