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 study group day 6
Search
Sponsored
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
mrkhutter
February 29, 2016
42
0
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
rails study group day 6
interacting with our models
mrkhutter
February 29, 2016
Transcript
21 slides
Rails Study Group
Pull Request • make code changes in feature branch •
git checkout -b feature/my_feature_branch • commit your code • use github to make a pull request
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
Create • your_variable = Model.new • your_model.save • your_model.save!
Validity • valid? • presence • length • format •
uniqueness • roll your own!
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
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
More Decks by mrkhutter
See All by mrkhutter
A Day in The Life
mrkhutter
0
110
rails group day 8
mrkhutter
0
51
rails group day 7
mrkhutter
0
41
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
How People are Using Generative and Agentic AI to Supercharge Their Products, Projects, Services and Value Streams Today
helenjbeal
2
410
Rails Girls Zürich Keynote
gr2m
96
14k
Product Roadmaps are Hard
iamctodd
55
13k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
Bash Introduction
62gerente
615
220k
Faster Mobile Websites
deanohume
310
32k
A Soul's Torment
seathinner
9
4k
Why Mistakes Are the Best Teachers: Turning Failure into a Pathway for Growth
auna
0
370
Imperfection Machines: The Place of Print at Facebook
scottboms
270
14k
Raft: Consensus for Rubyists
vanstee
143
7.9k
We Have a Design System, Now What?
morganepeng
55
8.4k
From Legacy to Launchpad: Building Startup-Ready Communities
dugsong
0
380