How do I create multiple views for a table in Rails 4


I have a single table in which I store favourite dishes of users. A user can have more than one entries in the table. I have generated a view to show all the entries in the table but how do I create a view to show just the list of users. I don't have a table saving the users so I have to use DISTINCT to get the names of the users from my one and only table

Sounds like you have a lot to learn about relational databases, schema design and data modeling so this answer might not help very much but here goes...

You're at a point where you should normalize your schema and put users in their own table. Then the dishes table would have a user_id field pointing back to the id of the user it belongs_to.

So, you'll have a User model that has_many Dishes. And a Dish model that belongs_to User. With that you'll more easily be able to create views for users without having to do a slightly complex query to get that data out of the Dish table.