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

RailsGirls Munich January 2016

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.

jng

January 30, 2016
Tweet

More Decks by jng

Other Decks in Programming

Transcript

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

    Ruby on Rails. – DAVID HEINEMEIER HANSSON Creator, Ruby on Rails http://rubyonrails.org/doctrine/ “
  2. 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
  3. Controller Responsibility View Update User Account id: 42 email: [email protected]

    Adjust id: 42 current_user.id email: [email protected] Controller 1 Model Database is safe Nothing happened to user #42 2
  4. 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
  5. 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
  6. 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
  7. 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;