accessing multiple values from hash ruby on rails

Viewed 94

This code snippet

room = Room.find(roomId)

returns a single column from room table, the returned value contains multiple attributes, like id, name, description, duration.

I want when coding

render json: room

to return only duration and name. Do i have to write something like that

render json: room[:duration, :name]
3 Answers
Related