Matched route patterns are available as parameters inside the Ruby code block. URL and form parameters are all also available.
- [Instructor] In the previous movie, we learned how to…create flexible route patterns.…Most of the time, if you want flexible routes,…then you also want your block of code…to be able to know what that matching text was…so that you could use the value in your code.…That's where route parameters are useful.…Route parameters allow you to have named wildcard matches,…and it stores them inside a hash called params.…A hash is the name in Ruby for key value pairs.…In other languages, they might be called a dictionary.…
So whatever values were matched will be stored…in the params hash.…Let me give you an example.…Say that we have our route that's get,…and then slash company slash splat, our wildcard operator.…We have access to whatever gets matched by that wildcard…operator because Sinatra automatically takes that matching…text and stores it in an array.…The array then is put inside the params hash…and given the key splat.…So we can access the values by going to params splat.…
Now, the reason it puts it in an array is because there…
- Installing Sinatra
- Launching the server
- Defining routes
- Using route patterns and parameters
- Redirecting requests
- Rendering dynamic templates
- Using partial templates and layouts
- Defining custom helpers
Skill Level Intermediate
Ruby on Rails 5 Essential Trainingwith Kevin Skoglund10h 21m Beginner
Ruby on Rails: Get More From ActiveRecordwith Kevin Skoglund4h 27m Intermediate
3. Helpers and Filters
4. Useful Techniques
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.