Created
January 20, 2015 19:31
-
-
Save cheezedigital/9395c42596c5b6315902 to your computer and use it in GitHub Desktop.
objects
This file contains 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
A class is used to create an object. It's like a blueprint | |
We have an Org class in the app | |
To create an Org object, we can do the following: Org.new | |
Or pull one from the database (orgs table): Org.find(ID) | |
The User class is also used to create objects | |
Under admin/users/index.html.haml we are looping through all the user objects in the database | |
users.each do |user| | |
... | |
end | |
Inside the block, the "user" variable contains one instance of an object | |
In the User class we have defined that the user belongs to an Org object | |
So we can call user.org to get the object | |
But we don't want to display the actual Org object to the user that is browsing the site because objects are only for us, developers, to use to create meaningful applications. | |
We want to display the name of the Org object because "name" is one of the attributes in the Org object. | |
Does that make sense? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment