0

I'm in the console, looking at someone else's app. I come across the following:

>> p.location
=> [#<Tag id: 2, name: "projects">]

Why do I see this result, which seems to be the object name, and how do I access the actual attribute name, "projects"?

>> p.location.name
=> "Tag"

Thank you very much!

1 Answer 1

6
p.location[0].name
## OR
p.location.first.name

p.location is an array of one element

Sign up to request clarification or add additional context in comments.

1 Comment

@Veep, you are just new to Rails. Also, if this answered your question, feel free to mark it as answered to that future people might find this to be a useful solution to their problem.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.