Index

A note on the digital index

A link in an index entry is displayed as the section title in which that entry appears. Because some sections have multiple index markers, it is not unusual for an entry to have several links to the same section. Clicking on any link will take you directly to the place in the text in which the marker appears.

A

:action parameter, Behind the scenes with routes, Behind the scenes with routes
actions, There’s a problem — people can’t find the pages they want, You need a form to submit data and an action method to save it
page templates and controller methods, Each page template now has a matching controller method, But how can a controller action display ANOTHER action’s page?
ActiveRecord, Rails is for database-centric apps like the ticket sales system
air reservation system (see Coconut Airways project)
Ajax, Ajax: Avoiding the traffic, The map could show more details
:full_page, But how do we convert the index page?
:show_action, But how do we convert the index page?
creating requests using, We need to create requests using Ajax, too
dynamically updating parts of web page, The form needs to update the contents of the pop-up’s <div>
generating Ajax form, The map partial lets us specify a “new” action
helpers, Tools for your Rails Toolbox
JavaScript generator, The controller needs to return JavaScript instead of HTML
libraries, First we need to include the Ajax libraries...
links, Ajax links to the rescue
timer events, But SHOULD we make the browser ask over and over again?
“Refresh” link, ...then we need to add an Ajax “Refresh” link
Ajax Exposed, You listen to a timer like you listen to a button
application framework, So what things do we need for the app?
architecture
MVC (see MVC architecture)
REST (see REST)
arrays, The data is returned as an object called an array
for loops, Read all of the ads with a for loop
index, An array is a numbered sequence of objects
partials, We also need a partial for the seat list
asynchronous requests, So what ELSE can make a request?, ...then we need to add an Ajax “Refresh” link
authenticity token, ...then we need to add an Ajax “Refresh” link
auto_discovery_link helper, Now let’s add the feed to the pages

B

background requests, So what ELSE can make a request?, So what effect does this code have?
belongs_to attribute, So what does the Seat model look like now?, Tools for your Rails Toolbox
browsers
asking for updates, The browser needs to ask for an update
JavaScript disabled, The form needs to update the contents of the pop-up’s <div>
updating entire page, Doesn’t the browser always update the entire page?
Bullet Points
background requests, So what effect does this code have?
belongs_to attribute, So what does the Seat model look like now?
controllers, The data’s in memory, and the web page can see it
CRUD operations, Create the table by running a migration
displaying data, So what does the generated HTML look like?
form_tag helper, So are the form parameters structured differently?
has_many attribute, So what does the Seat model look like now?
JavaScript events, So what effect does this code have?
migrations, The concert is a sell-out!
MVC architecture, The concert is a sell-out!
page sequences, So are the form parameters structured differently?
page templates, The data’s in memory, and the web page can see it
params[:field_name], So are the form parameters structured differently?
partials, So what does the Seat model look like now?
puts “A string”, So are the form parameters structured differently?
rails <app name>, Create the table by running a migration
rake db:migrate, The concert is a sell-out!
relationships, So what does the Seat model look like now?
routes, The data’s in memory, and the web page can see it
Ruby object, The data’s in memory, and the web page can see it
ruby script/server, Create the table by running a migration
scaffolding, Create the table by running a migration
validate method, So what does the Seat model look like now?
validators, Validators are simple and work well
XML HTTP Requests (XHRs), So what effect does this code have?
_tag fields, So are the form parameters structured differently?
business logic, The 3 parts of your app: model, view, and controller

C

calling methods on a nil object, Tools for your Rails Toolbox
CamelCase, Create the table by running a migration, But what about the controller?, Behind the scenes with routes
_ character, So how do we create the booking form partial?
class file for controller, But what about the controller?
Coconut Airways project, Coconut Airways need a booking system
excess baggage validation, But some people have too much baggage
reverse relationship, We need the REVERSE relationship
partials, We need the booking form and seat list on the flight page
array of seats, We also need a partial for the seat list
calling with render command, Now we need to include the partial in the template
creating, So how do we create the booking form partial?
local variables, We need to give the partial a seat!
relationships, People are ending up on the wrong flights
defining, But how do we define the relationship?
Test Drive, So what does the Seat model look like now?, If you don’t say where to put the response, it will be executed
confirmation message, The completed code can will now do several things
excess baggage validation, So what does the Seat model look like now?
hiding flight number field, You can pass local variables to a partial
initializing seat object, You can pass local variables to a partial
JavaScript button, ...then we need to add an Ajax “Refresh” link
JavaScript events, The form needs to be under the CONTROL of JavaScript
page fragment, We need a way to update just the seat list
relationships, But how do we define the relationship?
replacing create method, So what effect does this code have?
seat-list array, But the seat-list partial needs an array of seats
timer code, You listen to a timer like you listen to a button
viewing booking form, Now we need to include the partial in the template
updating only seat list, Which parts of a page change most?
browsers asking for updates, The browser needs to ask for an update
JavaScript form, The form needs to make an Ajax request
updating create method, We need to replace the create method
(see also Ajax)
:conditions parameter, Use :conditions to supply SQL
connecting models (see relationships)
:controller parameter, Behind the scenes with routes, Behind the scenes with routes
controller code, The 3 parts of your app: model, view, and controller
controller create method, The controller create method, step-by-step
controller methods, actions, Each page template now has a matching controller method
controllers, The data’s in memory, and the web page can see it
error messages, The controller needs to know if there was an error
formatted data, The form doesn’t send an object back, it sends DATA back
generate controller command, But what about the controller?, But what about the controller?
naming conventions, But what about the controller?
params[:action], Behind the scenes with routes
params[:controller], Behind the scenes with routes
sending data to view, The controller sends the ad to the view
Convention Over Configuration principle, Now you need to add your own code to the default app, Create the table by running a migration
create method, updating in Coconut Airways project, We need to replace the create method
crossword puzzles, Scaffoldless Grid, But what about the new static content MeBay sent over?
CRUD operations, Scaffolding is GENERATED code, Create the table by running a migration, We’re going to fix the scaffolding
custom pages, error messages, If you build your own pages, you need to write your own error message code

F

f.error_messages, We still need to display error messages!, The MeBay system is looking pretty sweet, Tools for your Rails Toolbox
:field_name parameter, So are the form parameters structured differently?
finders, Ad.find(:all) reads the whole table at once, There’s a finder for every attribute
:conditions, Use :conditions to supply SQL
attributes, There’s a finder for every attribute
database queries, Can you see a problem here?
matching this or that, We need to match either the client name OR the trainer name
versus relationships, We need to write our OWN validation
Finders Up Close, Can you see a problem here?
for loops, Read all of the ads with a for loop
formatted data, The form doesn’t send an object back, it sends DATA back
forms, You need a form to submit data and an action method to save it
Ajax requests, The form needs to make an Ajax request
associated with model object, Rails can create forms that are associated with model objects
creating object before displaying, The form object needs to be created before the form is displayed
in relation to objects, Are forms and objects related?
_tag fields, So are the form parameters structured differently?
form_for helper, Add the search to the interface, So why have two partials?
form_tag helper, Add the search to the interface, So are the form parameters structured differently?
:full_page parameter, But how do we convert the index page?
functional tests, So what kinds of tests are available?
functions, restricting access to, Restricting access to a function

G

Geek Bits
:xml render method, What will the controller code look like
CamelCase, But what about the controller?
Google Maps, The code will only work for localhost
helpers, Real-World Applications: Rails in the real world
SQLite3, There are no tables in the database yet!
Gem, Getting more information
gem server, Tools for your Rails Toolbox
generate controller command, But what about the controller?, But what about the controller?
generate model command, Let’s start by generating the MeBay model..., But what about the controller?
GET requests, So what’s an HTTP method?, So what’s an HTTP method?, The web application that went astray
getting started, Getting Started: Really Rapid Rails
application framework, So what things do we need for the app?
business logic, The 3 parts of your app: model, view, and controller
Convention Over Configuration principle, Now you need to add your own code to the default app, Create the table by running a migration
CRUD operations, Scaffolding is GENERATED code, Create the table by running a migration
database system, So what things do we need for the app?
Don’t Repeat Yourself principle, There are no tables in the database yet!
editing front page of web site, Now you need to add your own code to the default app
helpers, But changing the database isn’t enough
migrations, There are no tables in the database yet!, The application needs to store more information now, The concert is a sell-out!
rake command, You need to run your migration with rake
modifying applications, Sweet! You saved your buddy’s job!
MVC architecture, The 3 parts of your app: model, view, and controller, The concert is a sell-out!
view versus controller, The 3 parts of your app: model, view, and controller
naming conventions, Create the table by running a migration, Give your migration a “smart” name, and Rails writes your code for you
object-relational mapping library, So what things do we need for the app?
ActiveRecord, Rails is for database-centric apps like the ticket sales system
page templates, The 3 types of code are kept in SEPARATE folders
editing, But changing the database isn’t enough
rails <app name>, Create the table by running a migration
Rails architecture, To modify an app, you need to dig into the app’s architecture
rails command, You create a new application with the rails command, Create the table by running a migration
Rails development cycle, Edit the HTML in the view
rake command, Create the table by running a migration
rake db:migrate, You need to run your migration with rake, The concert is a sell-out!
ruby command, Create the table by running a migration
ruby script/server, So what does this do?, Create the table by running a migration
Ruby versus Rails, Now you need to add your own code to the default app
scaffold command, Scaffolding is GENERATED code, There are no tables in the database yet!
scaffolding, Scaffolding is GENERATED code, Create the table by running a migration
symbols, Edit the HTML in the view
Test Drive, So what does this do?, Edit the HTML in the view, But changing the database isn’t enough
creating tables with migration, Create the table by running a migration
scaffolding, So what does the scaffold command do?
timestamps and migrations, You need to run your migration with rake
web server, So what things do we need for the app?
Google Maps, The map could show more details
(see also Ajax)
:full_page, But how do we convert the index page?
:show_action, But how do we convert the index page?
generating Ajax form, The map partial lets us specify a “new” action
key, The code will only work for localhost
mashup, The new page needs a map... that’s the point!
generating XML mapping data, What do we need to generate?
mapping data, The code will only work for localhost
server, The new page needs a map... that’s the point!

H

has_many attribute, But how do we define the relationship?, We need the REVERSE relationship, We need the REVERSE relationship, So what does the Seat model look like now?
Head First Climbers project, Too many incidents!
converting index page, But how do we convert the index page?
editing pop-up windows, How things works now...
edit_incident route, We’re using the wrong route!
generating Ajax form, The map partial lets us specify a “new” action
Google Maps mashup, The new page needs a map... that’s the point!
generating XML mapping data, What do we need to generate?
mapping data, The code will only work for localhost
Google Maps server, The new page needs a map... that’s the point!
mapping location data, The data needs to be on a map
multiple representations, Meanwhile, at 20,000 feet...
which format gets requested, How does the map page work?
RSS feeds, RSS feeds are just XML
show_with_map action, We need to create a new action, We need to generate XML and HTML
Test Drive, What will the “show” action need to generate?, So what’s an HTTP method?
Ajax links, Ajax links to the rescue
Edit link added to the “show” partial, So how do we use the link_to helper?
Google Maps mashup, Now we need the map data, What will the controller code look like, What will the controller code look like, How should we decide which format to use?, The code is ready to go live, The code is ready to go live
map_info <div>, The form needs to update the contents of the pop-up’s <div>
pop-up form, The map partial lets us specify a “new” action
RSS feed, We’ll create an action called news, Now let’s add the feed to the pages
updating contents of pop-up’s <div>, The form needs to update the contents of the pop-up’s <div>
helpers, But changing the database isn’t enough, So what’s an HTTP method?, Real-World Applications: Rails in the real world
Ajax, Tools for your Rails Toolbox
auto_discovery_link, Now let’s add the feed to the pages
form_for, Add the search to the interface, So why have two partials?
form_tag, Add the search to the interface, So are the form parameters structured differently?
link_to, And we’ll also need a new link on the show page, So how do we use the link_to helper?
HTML
<link... /> reference, Now let’s add the feed to the pages
multiple representations, We need to generate XML and HTML
deciding which format to use, How should we decide which format to use?
which format gets requested, How does the map page work?
HTTP Authentication, Restricting access to a function
HTTP methods, The HTTP method affects the route that’s chosen, The web application that went astray
HTTP requests and responses, The controller needs to save the record

M

map partial, The form needs to update the contents of the pop-up’s <div>
_map.html.erb, So what code do we need?
map.resources, The code is ready to go live
mapping data, The data needs to be on a map, The code will only work for localhost
generating XML, What do we need to generate?
mashups, The new page needs a map... that’s the point!
MeBay project, MeBay, Inc. needs your help
@ad variable, The controller sends the ad to the view
default value, The @ad form object has not been created
actions, You need a form to submit data and an action method to save it
building applications without scaffolding, Scaffolding does WAY too much
controller create method, The controller create method, step-by-step
controllers sending data to view, The controller sends the ad to the view
controllers, formatted data, The form doesn’t send an object back, it sends DATA back
converting data to object before saving, Rails needs to convert the data into an object before it can be saved
converting records to objects, Rails turned the record into an object
deleting data, ...but now old ads need to be deleted
forms, You need a form to submit data and an action method to save it
associated with model objects, Rails can create forms that are associated with model objects
creating object before displaying, The form object needs to be created before the form is displayed
in relation to objects, Are forms and objects related?
generate controller command, But what about the controller?
index page
arrays, The data is returned as an object called an array
finder methods, Ad.find(:all) reads the whole table at once
generating hyperlinks for each element, We need HTML for each element in the array
reading all records, An index page will need data from ALL of the records
index page, building, There’s a problem — people can’t find the pages they want
inserting data, People want to post new ads online
layouts, But there are two page templates... should we change the code of each one?
migration, ...and then we’ll actually create the table using rake
model-generator command, Let’s start by generating the MeBay model...
MVC architecture, Scaffolding does WAY too much
page templates, The view is created with a page template
adding loops with scriptlets, Loops can be added to page templates using scriptlets
converting into Ruby code, Rails converts page templates into Ruby code
matching controller method, Each page template now has a matching controller method
reusing, Don’t create a new page, use an existing one
single template that controls other templates, But there are two page templates... should we change the code of each one?
rake db:migrate command, ...and then we’ll actually create the table using rake
redirects, Redirects let the controller specify which view is displayed
routes, A route tells Rails where your web page is
priority, There’s a problem — people can’t find the pages they want
Ruby expressions, The data’s in memory, and the web page can see it
saving data, You already know how to build an app that publishes data from the database
securing applications, restricting access to functions, Restricting access to a function
sending data to view, The view doesn’t have the data to display app
Test Drive, The page template contains HTML
blank ads, Behind the scenes with routes
controller code, Each page template now has a matching controller method
create.html.erb page template, Rails was complaining because it had no way of generating a RESPONSE to your request
custom page control, The controller needs to know if there was an error
deleting ads from site, ...but now old ads need to be deleted
edit.html.erb page template, Instead of creating an ad, you need to find one; instead of saving it, you need to update the ad
layouts, But there are two page templates... should we change the code of each one?
new index page, So what does the generated HTML look like?
page template for the “new” form, Rails can create forms that are associated with model objects
records converted to objects, The data’s in memory, and the web page can see it
redirects, Redirects let the controller specify which view is displayed
security code, Restricting access to a function
updating controller’s create method, The controller needs to save the record
validation, We still need to display error messages!
updating data, But what if an ad needs to be amended after it’s been posted?
validation, Something strange has happened at MeBay
displaying error messages, We still need to display error messages!
error messages and controllers, The controller needs to know if there was an error
validators not displaying errors, The validators work, but they don’t display errors
methods returning true or false, So why have two partials?
migrations, There are no tables in the database yet!, The application needs to store more information now, The concert is a sell-out!
MeBay project, ...and then we’ll actually create the table using rake
rake command, You need to run your migration with rake
timestamps, You need to run your migration with rake
model code, The 3 parts of your app: model, view, and controller
model form, The search will need a new kind of form, Add the search to the interface
model objects, The data is returned as an object called an array
forms associated with, Rails can create forms that are associated with model objects
generating XML, We’ll generate XML from the model
skipping validation, How do we check for mandatory fields?
models
connecting (see relationships)
generate model command, Let’s start by generating the MeBay model..., But what about the controller?
naming conventions, But what about the controller?
validating in, Watch out—there’s bad data in the room
modifying applications, Sweet! You saved your buddy’s job!
multiple representations, Meanwhile, at 20,000 feet...
deciding which format to use, How should we decide which format to use?
resources, XML and HTML are just representations
which format gets requested, How does the map page work?
MVC architecture, The 3 parts of your app: model, view, and controller, The concert is a sell-out!
MeBay project, Scaffolding does WAY too much
view versus controller, The 3 parts of your app: model, view, and controller
MySQL databases, So how do you change the database?

N

naming conventions, Create the table by running a migration, Give your migration a “smart” name, and Rails writes your code for you
controllers, But what about the controller?
models, But what about the controller?
tables, But what about the controller?
new_<model_name>_path, Tools for your Rails Toolbox
nil, The @ad form object has not been created
calling methods on a nil object, Tools for your Rails Toolbox
No Dumb Questions
:id, Behind the scenes with routes
actions, There’s a problem — people can’t find the pages they want
Ajax forms, So what effect does this code have?
arrays, An array is a numbered sequence of objects
asynchronous requests, ...then we need to add an Ajax “Refresh” link
authenticity token, ...then we need to add an Ajax “Refresh” link
business logic, The 3 parts of your app: model, view, and controller
calling render, How does the map page work?
CamelCase, Behind the scenes with routes
Convention over Configuration principle, Create the table by running a migration
databases, There’s a problem — people can’t find the pages they want
editing front page of web site, Now you need to add your own code to the default app
examining tables, But what about the controller?
form_tag versus form_for, So are the form parameters structured differently?
generate controller command, But what about the controller?
generate model command, But what about the controller?
GET and POST requests, So what’s an HTTP method?
Google Maps, The form needs to update the contents of the pop-up’s <div>
helpers, But changing the database isn’t enough, So what’s an HTTP method?
JavaScript, ...then we need to add an Ajax “Refresh” link
JavaScript disabled, The form needs to update the contents of the pop-up’s <div>
local variables, You can pass local variables to a partial
map partial, The form needs to update the contents of the pop-up’s <div>
map.resources, The code is ready to go live
methods returning true or false, So why have two partials?
migration, A migration is just a Ruby script
model form, The search will need a new kind of form
non-model form, The search will need a new kind of form
page templates, There’s a problem — people can’t find the pages they want
partials, You can pass local variables to a partial, So what does the Seat model look like now?
primitives, There’s a problem — people can’t find the pages they want
PUT and DELETE requests, So what’s an HTTP method?
rails command, Create the table by running a migration
rake command, Create the table by running a migration
rake db:migrate command, But what about the controller?
redirects, Redirects let the controller specify which view is displayed
render method, What will the controller code look like
requests, Behind the scenes with routes
responses, Behind the scenes with routes
REST, How does the map page work?
RESTful design, So what’s an HTTP method?
route configuration, Behind the scenes with routes
ruby command, Create the table by running a migration
ruby script/server, Now you need to add your own code to the default app
Ruby versus Rails, Now you need to add your own code to the default app
saved objects, So why have two partials?
scaffolding, Behind the scenes with routes, The search will need a new kind of form
strings as paths, So what’s an HTTP method?
symbols, Edit the HTML in the view
timer events, You listen to a timer like you listen to a button
validation
asking model object to skip, How do we check for mandatory fields?
changing error messages, How do we check for mandatory fields?
validators, How do we check for mandatory fields?
view versus controller, The 3 parts of your app: model, view, and controller
non-model form, The search will need a new kind of form, Add the search to the interface

P

page fragments, We need a way to update just the seat list, What will the “show” action need to generate?
page sequences, So are the form parameters structured differently?
page templates, The 3 types of code are kept in SEPARATE folders, The data’s in memory, and the web page can see it, There’s a problem — people can’t find the pages they want, How can we split a page’s content up into separate files?
actions, But how can a controller action display ANOTHER action’s page?
adding loops with scriptlets, Loops can be added to page templates using scriptlets
converting into Ruby code, Rails converts page templates into Ruby code
editing, But changing the database isn’t enough
Embedded Ruby (ERb), The view is created with a page template
matching controller method, Each page template now has a matching controller method
partial (see partials)
reusing, Don’t create a new page, use an existing one
single template that controls other templates, But there are two page templates... should we change the code of each one?
partials, We need the booking form and seat list on the flight page, How can we split a page’s content up into separate files?, So what does the Seat model look like now?
arrays, We also need a partial for the seat list
calling with render command, Now we need to include the partial in the template
creating, So how do we create the booking form partial?
local variables, We need to give the partial a seat!
passing variable to, Tools for your Rails Toolbox
passwords, Restricting access to a function
_path, Tools for your Rails Toolbox
Pool Puzzle
Coconut Airways project, You can pass local variables to a partial
getting started, So how does Rails help us?
MeBay project, The data’s in memory, and the web page can see it
validation, The controller needs to know if there was an error
XML builder template, So we’ll use a new kind of template: an XML builder
pop-up windows, updating contents, The form needs to update the contents of the pop-up’s <div>
POST requests, So what’s an HTTP method?, So what’s an HTTP method?, The web application that went astray
primitives, There’s a problem — people can’t find the pages they want
Prototype library, First we need to include the Ajax libraries...
Google Maps, The form needs to update the contents of the pop-up’s <div>
Protoype library, Tools for your Rails Toolbox
PUT requests, So what’s an HTTP method?, The web application that went astray
puts <string>, So are the form parameters structured differently?, Tools for your Rails Toolbox

R

Rails
architecture, To modify an app, you need to dig into the app’s architecture
development cycle, Edit the HTML in the view
environments, Going live
helpers, But changing the database isn’t enough, Real-World Applications: Rails in the real world
JavaScript generator, The controller needs to return JavaScript instead of HTML
primitives, There’s a problem — people can’t find the pages they want
versus Ruby, Now you need to add your own code to the default app
rails <app name>, Create the table by running a migration
rails command, Create the table by running a migration
file generation, You create a new application with the rails command
Rails Exposed, The 3 parts of your app: model, view, and controller
Rails principles
Convention Over Configuration, Now you need to add your own code to the default app, Create the table by running a migration
Don’t Repeat Yourself, There are no tables in the database yet!
Rails resources
books, A little light reading...
built-in documentation, Getting more information
web sites, Getting more information
Rails Toolbox
Rails Tools
:only parameter, Tools for your Rails Toolbox
:root parameter, Tools for your Rails Toolbox
<route name>_path(object), Tools for your Rails Toolbox
@ad.save, Tools for your Rails Toolbox
@ad.update_attributes, Tools for your Rails Toolbox
Ajax applications, Tools for your Rails Toolbox
Ajax helpers, Tools for your Rails Toolbox
changing “_path” to “_url”, Tools for your Rails Toolbox
edit_<model_name>_path(object), Tools for your Rails Toolbox
errors.add_to_base(...), Tools for your Rails Toolbox
f.error_messages, Tools for your Rails Toolbox
find(:all, :conditions=>[...]), Tools for your Rails Toolbox
form_tag, Tools for your Rails Toolbox
gem server, Tools for your Rails Toolbox
helpers, Tools for your Rails Toolbox
http_authentication, Tools for your Rails Toolbox
new_<model_name>_path, Tools for your Rails Toolbox
passing variable to partial, Tools for your Rails Toolbox
Protoype library, Tools for your Rails Toolbox
rails app-name, Tools for your Rails Toolbox
RAILS_ENV=production, Tools for your Rails Toolbox
rake db:migrate, Tools for your Rails Toolbox
rake rails:freeze:edge, Tools for your Rails Toolbox
rake routes, Tools for your Rails Toolbox
redirect_to, Tools for your Rails Toolbox
render :action=>’new’, Tools for your Rails Toolbox
render :partial=>”name”, Tools for your Rails Toolbox
render :template=>”a/template”, Tools for your Rails Toolbox
responders, Tools for your Rails Toolbox
respond_to, Tools for your Rails Toolbox
ri <something>, Tools for your Rails Toolbox
Ruby language, Tools for your Rails Toolbox
ruby script/generate controller, Tools for your Rails Toolbox
ruby script/generate migration, Tools for your Rails Toolbox
ruby script/generate model, Tools for your Rails Toolbox
ruby script/generate scaffold, Tools for your Rails Toolbox
ruby script/server, Tools for your Rails Toolbox
save method, Tools for your Rails Toolbox
to_xml, Tools for your Rails Toolbox
update_attributes method, Tools for your Rails Toolbox
validates_format_of, Tools for your Rails Toolbox
validates_inclusion_of, Tools for your Rails Toolbox
validates_length_of, Tools for your Rails Toolbox
validates_uniqueness_of, Tools for your Rails Toolbox
XML builder templates, Tools for your Rails Toolbox
_responder_ object, Tools for your Rails Toolbox
Ruby Tools
arrays, Tools for your Rails Toolbox
arrays, looping through, Tools for your Rails Toolbox
calling methods on a nil object, Tools for your Rails Toolbox
nil, Tools for your Rails Toolbox
params[...], Tools for your Rails Toolbox
puts <string>, Tools for your Rails Toolbox
“#{“ and ”}”, Tools for your Rails Toolbox
RAILS_ENV variable, Going live
RAILS_ENV=production, Tools for your Rails Toolbox
rake command, Create the table by running a migration
migrations, You need to run your migration with rake
rake db:migrate command, Create the table by running a migration, You need to run your migration with rake, The concert is a sell-out!, ...and then we’ll actually create the table using rake, But what about the controller?
rake rails:freeze:edge, Tools for your Rails Toolbox
rake routes, Tools for your Rails Toolbox
Ready Bake Code, layout file for Rubyville Health Club project, Add the search to the interface
Ready Bake Sign-In Code, Restricting access to a function
Ready Bake Super-Template Code, A layout defines a STANDARD look for a whole set of page templates
records
converting to objects, Rails turned the record into an object
finding client records in Rubyville Health Club project, How do we find client records?
redirects, Redirects let the controller specify which view is displayed
relationships, People are ending up on the wrong flights
defining, But how do we define the relationship?
excess baggage validation, But some people have too much baggage
reverse, We need the REVERSE relationship
versus finders, We need to write our OWN validation
Relationships Up Close, A relationship connects models together
render command
calling, How does the map page work?
calling partial, Now we need to include the partial in the template
render method, What will the controller code look like
:xml, What will the controller code look like
requests, Behind the scenes with routes, The controller needs to save the record, The browser needs to ask for an update
Ajax, The form needs to make an Ajax request
asynchronous, So what ELSE can make a request?, ...then we need to add an Ajax “Refresh” link
background, So what ELSE can make a request?, So what effect does this code have?
JavaScript, So what ELSE can make a request?
XML HTTP Requests (XHRs), So what effect does this code have?
required fields, validating, Users have been leaving out data on their workout forms
reservation system (see Coconut Airways project)
resources, XML and HTML are just representations
_responder_ object, Tools for your Rails Toolbox
responders, Tools for your Rails Toolbox
respond_to, Tools for your Rails Toolbox
respond_to do method, How should we decide which format to use?
responses, Behind the scenes with routes, The controller needs to save the record, The browser needs to ask for an update
REST, XML and HTML are just representations, How does the map page work?, What’s REST?
RESTful design, So what’s an HTTP method?
RESTful Routes Up Close, So how do we use the link_to helper?
reusing existing page template, Don’t create a new page, use an existing one
ri <something>, Getting more information, Tools for your Rails Toolbox
:root parameter, Tools for your Rails Toolbox
<route name>_path(object), Tools for your Rails Toolbox
routes, A route tells Rails where your web page is, The data’s in memory, and the web page can see it
:action, Behind the scenes with routes
:controller, Behind the scenes with routes
configuration, Behind the scenes with routes
params[:action], Behind the scenes with routes
params[:controller], Behind the scenes with routes
priority, There’s a problem — people can’t find the pages they want
Routing Exposed, Routes run in priority order
RSS feeds, RSS feeds are just XML
Ruby
ERb (see ERb (Embedded Ruby))
expressions, The data’s in memory, and the web page can see it
for loop, Read all of the ads with a for loop
methods returning true or false, So why have two partials?
objects, The data’s in memory, and the web page can see it
primitives, There’s a problem — people can’t find the pages they want
Try this!, Look! It’s a big Ruby “Try this” page
versus Rails, Now you need to add your own code to the default app
ruby command, Create the table by running a migration
Ruby language, Tools for your Rails Toolbox
ruby script/server, So what does this do?, Create the table by running a migration
Rubyville Health Club project, Keep fit with the Rubyville Health Club
CRUD operations, We’re going to fix the scaffolding
database queries, modifying conditions, We need to be able to modify the conditions used in the SQL query
determining to fix scaffolding or write new code, Keep fit with the Rubyville Health Club
finders, There’s a finder for every attribute
:conditions, Use :conditions to supply SQL
attributes, There’s a finder for every attribute
database queries, Can you see a problem here?
matching this or that, We need to match either the client name OR the trainer name
finding client records, How do we find client records?
layout file, Add the search to the interface
search function, Design the search function
adding to interface, Add the search to the interface
building form, Let’s start by building the form
Test Drive, Keep fit with the Rubyville Health Club, So what’s next?
layout including search functionality, Add the search to the interface
search functionality, So are the form parameters structured differently?
updating finder code, Use :conditions to supply SQL
validators, Let’s check if something is a number, How do we check for mandatory fields?
validating data, Watch out—there’s bad data in the room
in model, Watch out—there’s bad data in the room
simple validation (see validators)
validating required fields, Users have been leaving out data on their workout forms

V

validate method, But some people have too much baggage, So what does the Seat model look like now?, Tools for your Rails Toolbox
validates_format_of, How do we check for mandatory fields?, How do we check for mandatory fields?, Tools for your Rails Toolbox
validates_inclusion_of, How do we check for mandatory fields?, How do we check for mandatory fields?, Tools for your Rails Toolbox
validates_length_of, How do we check for mandatory fields?, How do we check for mandatory fields?, Tools for your Rails Toolbox
validates_numericality_of, Let’s check if something is a number
validates_presence_of, How do we check for mandatory fields?
validates_uniqueness_of, How do we check for mandatory fields?, How do we check for mandatory fields?, Tools for your Rails Toolbox
validation, Validating your Data: Preventing mistakes
asking model object to skip, How do we check for mandatory fields?
error messages
changing, How do we check for mandatory fields?
custom pages, If you build your own pages, you need to write your own error message code
displaying, We still need to display error messages!
excess baggage (Coconut Airways project), But some people have too much baggage
MeBay project, Something strange has happened at MeBay
displaying error messages, We still need to display error messages!
error messages and controllers, The controller needs to know if there was an error
Rubyville Health Club project, Watch out—there’s bad data in the room
simple (see validators)
validating in model, Watch out—there’s bad data in the room
validators
checking if number, Let’s check if something is a number
how validators work, So how do validators work?
not displaying errors, The validators work, but they don’t display errors
required fields, Users have been leaving out data on their workout forms
validates_numericality_of, Let’s check if something is a number
validates_presence_of, How do we check for mandatory fields?
variables
local, We need to give the partial a seat!
passing variable to partial, Tools for your Rails Toolbox
view code, The 3 parts of your app: model, view, and controller
editing, The 3 types of code are kept in SEPARATE folders
page templates (see page templates)
views
controllers sending data to, The controller sends the ad to the view
sending data to, The view doesn’t have the data to display app
versus controllers, The 3 parts of your app: model, view, and controller
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.142.171.180