Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Ruby Build a Simple Ruby on Rails Application Customizing Forms Adding a Dropdown

:full_name

Why does full_name need to be passed in as a symbol?

Juan Ordaz
Juan Ordaz
12,012 Points

I will try to explained how I see it. This might not be the right or proper answer, But I love helping.

    def full_name
        first_name + " " + last_name
    end

the method full_name here return a string(value), which is first_name and last name. In your console do a query

User.last 

You will see that all attributes with its values are inside an ARRAY, those are symbols with values. To have access to an attribute of the last User, you have to make a query

User.last[:first_name]

The query above will return a string of whatever the first name is. In your model you are making like an extra attribute(think about it this way), that will not be save in your database as a column, but is helping you retrieve two attributes easier at the same time. So, To display the value of the full_name method in the views(remember pretend is an attribute or symbol), you have to treat the full_name method like if it is an attribute in your database. In other words, to show the value of the full name, you have to write as a symbol(attribute), because it contains a value, which is Pancho Villa.

I hope this is a good explanations [http://ruby-doc.org/core-2.2.0/Symbol.html]