RailsGirls Munich January 2016

F4612f9492cccc0c61c9b5f80d0ca8a1?s=47 jng
January 30, 2016

RailsGirls Munich January 2016

An introduction to Rails for total beginners. Goal is to understand how the Rails structure is so we know where to find things.

F4612f9492cccc0c61c9b5f80d0ca8a1?s=128

jng

January 30, 2016
Tweet

Transcript

  1. Finding your way in Rails Julie Ng RailsGirls
 Munich, Germany

    30 January 2016
  2. Is Rails magic?

  3. Optimizing for happiness is perhaps the most formative key to

    Ruby on Rails. – DAVID HEINEMEIER HANSSON Creator, Ruby on Rails http://rubyonrails.org/doctrine/ “
  4. Convention vs Configuration

  5. What is MVC? Controller(s) Model(s) View(s) (Rails flavored. Extremely simplified)

    Presentation Layer Coordination Layer Data Layer
  6. 1 MVC per Representation Idea User Attachment Idea Model Ideas

    Controller Ideas Views Attachment Model Attachments Controller Attachments Views User Model Users Controller Users Views
  7. Controller Responsibility View Update User Account id: 42 email: hijacked@email.com

    Adjust id: 42 current_user.id email: hijacked@email.com Controller 1 Model Database is safe Nothing happened to user #42 2
  8. Model Responsibility Controller Model Create new user username: railsGirls email:

    hi@railsGirls 1 Username must be unique. Email invalid. 2 Display formatted error messaging: "Please choose another username." "Please check your email address." View 3
  9. “ Phew! ” For the purpose of RailsGirls
 you'll mostly

    customize your app in Views
  10. Where in Rails… $ rails generate scaffold bike name:string, wheels:integer

    invoke active_record create app/models/bike.rb invoke scaffold_controller create app/controllers/bikes_controller.rb invoke erb create app/views/bikes create app/views/bikes/index.html.erb create app/views/bikes/edit.html.erb create app/views/bikes/show.html.erb create app/views/bikes/new.html.erb create app/views/bikes/_form.html.erb invoke assets invoke js create app/assets/javascripts/bikes.js invoke scss create app/assets/stylesheets/bikes.scss
  11. Where in Rails… $ rails generate scaffold bike name:string, wheels:integer

    invoke active_record create app/models/bike.rb invoke scaffold_controller create app/controllers/bikes_controller.rb invoke erb create app/views/bikes create app/views/bikes/index.html.erb create app/views/bikes/edit.html.erb create app/views/bikes/show.html.erb create app/views/bikes/new.html.erb create app/views/bikes/_form.html.erb invoke assets invoke js create app/assets/javascripts/bikes.js invoke scss create app/assets/stylesheets/bikes.scss
  12. What are assets? app ├── assets │ ├── images │

    │ ├── logo.jpg │ ├── javascripts │ │ ├── application.js │ │ ├── bikes.js │ └── stylesheets │ ├── application.scss │ ├── bikes.scss Part of the Presentation Layer Images
 Graphics JavaScript
 Interaction
 alert('Are you sure?'); Stylesheets
 Style Language
 width: 100px;
 font-size: 12px;
 color: red;
  13. The "Application" views/layouts/application.html.erb app/views/bikes app/views/bikes/index.html.erb app/views/bikes/edit.html.erb app/views/bikes/show.html.erb app/views/bikes/new.html.erb app/views/bikes/_form.html.erb views/bikes/edit.html.erb

    views/bikes/_form.html.erb My awesome App Footer
  14. Julie Ng @jng5 julie.io Fin