Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Getting Started with Ruby on Rails
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
Vero Rebagliatte
June 12, 2013
160
0
Share
Getting Started with Ruby on Rails
Vero Rebagliatte
June 12, 2013
More Decks by Vero Rebagliatte
See All by Vero Rebagliatte
Trained Model for Breast Cancer Detection
rebagliatte
0
100
A programmer's cycle
rebagliatte
1
220
Card Sorting
rebagliatte
0
2.1k
An introduction to Backbone.js
rebagliatte
6
5.1k
Introducción al Diseño de Interacción
rebagliatte
4
1.2k
Featured
See All Featured
A brief & incomplete history of UX Design for the World Wide Web: 1989–2019
jct
1
350
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Ten Tips & Tricks for a 🌱 transition
stuffmc
0
99
Taking LLMs out of the black box: A practical guide to human-in-the-loop distillation
inesmontani
PRO
3
2.1k
Bash Introduction
62gerente
615
210k
[Rails World 2023 - Day 1 Closing Keynote] - The Magic of Rails
eileencodes
38
2.8k
Collaborative Software Design: How to facilitate domain modelling decisions
baasie
1
200
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
231
23k
How to build a perfect <img>
jonoalderson
1
5.4k
How to Align SEO within the Product Triangle To Get Buy-In & Support - #RIMC
aleyda
2
1.5k
Writing Fast Ruby
sferik
630
63k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
2
1k
Transcript
GETTING STARTED WITH RUBY ON RAILS
@rebagliatte Vero Rebagliatte
Forecast 1. What’s ROR? 2. The rails way 3. Example
app
What’s ROR?
It’s a framework
Was created by DHH
Lowers the barrier to start programming in Ruby
Opinionated
The Rails Way
Be DRY, don’t repeat yourself
Prefer convention over configuration
Be RESTful
REST uses operations of the HTTP protocol
REST GET PUT POST PATCH DELETE SOAP getUsers() getNewUsersSince() savePurchaseOrder()
getUser() addUser() removeUser() updateUser() getLocation()
REST uses resources
http://myblog.com/posts/ GET PUT POST DELETE http://myblog.com/posts/1 GET PUT POST DELETE
} }
Blog::Application.routes.draw do resources :posts end config/routes.rb
Use the MVC (Model View Controller) Pattern
None
class Post < ActiveRecord::Base attr_accessible :content, :name, :title has_many :commenters
validates :title, presence: true end app/models/post.rb
<h1>Post <%= @post.title %> </h1> <%= @post.content %> <%= link_to
'Edit', edit_post_path(@post) %> <%= link_to 'Back', posts_path %> app/views/posts/show.rb
class PostsController < ApplicationController def new @post = Post.new end
def create @post = Post.new(params[:post]) if @post.save redirect_to @post, notice: 'Post created!' else render action: :new end end end app/controllers/posts_controller.rb
None
Package your code for reuse
source 'https://rubygems.org' gem 'rails', '3.2.13' gem 'sqlite3' group :assets do
gem 'sass-rails', '~> 3.2.3' gem 'coffee-rails', '~> 3.2.1' gem 'uglifier', '>= 1.0.3' end gem 'jquery-rails' Gemfile
Be fast by default with the Asset Pipeline
None
app/assets assets from the current application lib/assets your own libraries,
shared across applications vendor/assets third party assets(js plugins, css frameworks)
PRECOMPILE
None
CONCATENATE
None
application.css application.js logo.jpg application-908e25f4bf641 868d8683022a5b62f54.css application-908e25f4bf641 868d8683022a5b62f54.js logo-908e25f4bf641868d8 683022a5b62f54.jpg ADD
MD5 FINGERPRINT
COMPRESS
More
Internationalize your app
Use generators
Example App
None
Thanks! @rebagliatte