Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
rails group day 7
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mrkhutter
March 01, 2016
41
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
rails group day 7
model actions and routing
mrkhutter
March 01, 2016
Transcript
29 slides
Rails Study Group
Git Flow • to start: always git pull origin <branch>
• git checkout -b feature/my_feature_branch • write the code! • commit your code • git add path/to/files • git commit -m “your commit message” • git push • use github.com to make a pull request
MVC
MVC
MVC
MVC
MVC
MVC
Model Review
Create • your_variable = Model.new • your_model.save • your_model.save!
Find • Model.find(:id) • Model.find_by(attribute: value) • Model.find_by_attribute(value)
Index • Do you want to find a model by
attribute? • Prevents “full table scan” • To add index • rails g migration AddIndexToTableColumn
Update • updates update_at timestamp • direct update with resave
• update_attribute(:attribute, value) • update_attributes(attribute1: value, attribute2:value)
Destroy • a_model_instance.destroy
Validity • valid? • presence • length • format •
uniqueness • roll your own!
Tests • Especially important for teams without QA • Ruby
is dynamically typed - make sure you get what you are expecting • Provides a developer confidence in their code
Tests • They are auto-magically created for you!
Tests (green)
Tests (red)
Model Errors
Skinny Controller Fat Model
Routes
config/routes.rb
CRUD, Verbs, & Actions
CRUD, Verbs, & Actions
Path and URL Helpers
Route Restsrictions
rake routes
Reference • https://www.w3.org/Protocols/rfc2616/rfc2616- sec9.html • http://guides.rubyonrails.org/routing.html • https://www.railstutorial.org/book/ filling_in_the_layout
More Decks by mrkhutter
See All by mrkhutter
A Day in The Life
mrkhutter
0
110
rails group day 8
mrkhutter
0
51
rails study group day 6
mrkhutter
0
42
rails study group day 5
mrkhutter
0
36
shipt rails study group day 4
mrkhutter
0
34
shipt rails study group day 3
mrkhutter
0
40
Rails Study Group Day 1
mrkhutter
0
60
Featured
See All Featured
SEO in 2025: How to Prepare for the Future of Search
ipullrank
3
3.9k
The Myth of the Modular Monolith - Day 2 Keynote - Rails World 2024
eileencodes
28
3.8k
Paper Plane (Part 1)
katiecoart
PRO
3
12k
A designer walks into a library…
pauljervisheath
211
25k
AI Search: Where Are We & What Can We Do About It?
aleyda
0
8.3k
Jess Joyce - The Pitfalls of Following Frameworks
techseoconnect
PRO
1
480
Organizational Design Perspectives: An Ontology of Organizational Design Elements
kimpetersen
PRO
1
890
HDC tutorial
michielstock
2
1k
How To Stay Up To Date on Web Technology
chriscoyier
790
250k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
35
2.9k
How GitHub (no longer) Works
holman
316
150k
A Guide to Academic Writing Using Generative AI - A Workshop
ks91
PRO
1
580