From the course: Ruby on Rails 6 Essential Training
Unlock the full course today
Join today to access over 22,400 courses taught by industry experts or purchase this course individually.
Using partials and helpers to organize code - Ruby on Rails Tutorial
From the course: Ruby on Rails 6 Essential Training
Using partials and helpers to organize code
- In this movie, I want to introduce you to partials and helpers. Partials and helpers are important for having good code organization in your Ruby on Rails project. And most importantly they help you to not repeat yourself. And remember that's one of the fundamental mantras. Dry don't repeat yourself. Partials are going to be partial templates and we want to create partial templates that we can share between a number of other templates. Helpers are methods that can be called in the view templates. So we can move Ruby code into those helpers and call on it when needed. In the last movie you may have noticed that our new form and our edit form have a lot of code in common especially this table of form fields. What I want to do now is use a partial so that they can share that same information and we won't have to repeat it anymore. The convention for doing that is to create a new file inside the subjects and we're…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
Read action: Index4m 20s
-
Read action: Show4m
-
Adding basic forms to templates4m 51s
-
Create action: New4m 12s
-
Create action: Create5m 5s
-
Using strong parameters to regulate input4m 57s
-
Update actions: Edit and update6m 19s
-
Using partials and helpers to organize code6m 36s
-
Delete actions: Delete and destroy5m 50s
-
Challenge: Pages CRUD1m 23s
-
Solution: Pages CRUD4m 50s
-
-