Reputation: 853
I have a model with some attributes.
If I display all records in JSON format
respond_with(Group.all)
It shows all records with corresponding attribute names. I want to display all records except some column records. So, I used
@groupDetails = Group.pluck(:id,:name,:created_at)
respond_with(@groupDetails)
It shows all specified attribute records, but I want all these records with corresponding attribute names.
Upvotes: 1
Views: 31
Reputation: 17647
You want the select method:
Group.select(:id,:name,:created_at)
Upvotes: 1