RoR: What is it Good For?: Absolutely Something
-
Upload
kdmcclin -
Category
Technology
-
view
55 -
download
1
Transcript of RoR: What is it Good For?: Absolutely Something
If Rails is the Creature
▪ David Heinemeier Hansson (DHH)
▪ Drives racecars
▪ Created Rails for speed, self-reliance, and programmer happiness
▪ "If we don't have toys, we're just adults."
View
▪ What a user sees
▪ .ERB (embedded ruby) files as default – Mixes Ruby syntax with
HTML syntax in .html.erb files
But Wait, There’s More
▪ Rails provides a number of helpful additions to your views– Form helpers– URL helpers
▪ Partials – Templates that let you use
the same view section multiple places
– Especially useful for forms▪ _form.html.erb
Controller
▪ Where the action’s at
▪ Receives requests for the application
▪ Determines what information the view should display
▪ Sends commands to the model to change/update any data
▪ Ruby (.rb) file
Model
▪ Determines how data is stored and structured
▪ Less about the action, more about the inherent nature or state of the information
▪ Ruby (.rb) file
Database Migrations
▪ Ruby classes that are designed to make it simple to create and modify database tables
▪ automatically generated when you generate a model– Can be generated
separately
▪ create the database tables when run
Relationships
▪ Declared in the models
▪ One to one– Users and social media profiles▪ A user only has_one Facebook profile, and that profile only belongs_to that user
▪ One to many– Users and orders▪ A user has_many orders, and each order only belongs_to that user
▪ Many to many– Writing prompts and categories▪ Categories can contain many prompts, and those prompts can belong to many
categories
– Join table prompt_categories– A prompt has_many :prompt_categories
has_many :categories, through: :prompt_categories– A prompt category belongs_to prompts AND categories
Gems
▪ Ruby recap:– Gems are packaged bits of
code other people have written
▪ Rails is a gem!
▪ People frequently use gems to:– Handle user authentication– Write tests for their code– Separate data chunks into
pages– Create fake data
▪ Gems go in your Gemfile
Katherine McClintic
Web Developer. Teacher. Musician. Fencer. Person who likes to take things
apart and usually puts them back together in working order-er.
@scarletalphabet
Rails Lead for Women Who Code DC meetup