You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was a question from @photonerddan during class, and after looking through many examples online approaching it from an inheritance stance, as well as ones with examples that seemed outside of common use-cases, Mike and I decided to approach it from a problem / solution standpoint, which looks at it from a database perspective.
We will cover it more in-depth during the second week of Rails MakerSquare, but for now here is a short example to highlight the problem that polymorphism is solving in your database.
So let's start with the problem it is solving:
Polymorphism keeps you from having excessive foreign key columns in a database table where multiple things, such as notification feed items, are owned by other objects.
email gravatar each loop. outputs a hash of all the emails input
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Up until now we have looked at the create and update controller action in Rails in the context of using a basic <html> form tag, <form></form>.
When you wanted to POST a new movie to your Metube app:
'new' action
First you made a new controller-action in your videos controller. This action was mapped to the GET route that loaded the new video form from the views/videos/new.html.erb file with a route that looks like get "/videos/new", to: "videos#new" in the routes.rb file.
Looking at the new action in the videos controller, it's time to come clean. There was really no reason in the previous Rails CRUD lesson with the new action that we needed to hand down this instance variable:
I was thinking about an image rotator and started mocking one up on a small scale.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show commenting out require relatives and putting in the directory files in a single line
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters