I need to have one table in which i can set user preferences I want to have one table in which all preferences values are set and another relation table in which i will have user_id and the preference_id but I need to have preference for three different pages
- item
- favorite
- recent.
I need to show the list of results as set by user for e.g if on item page user wants 20 results to be shown then I want to set prference id set as 1 which as value 20.
prefrence table
id
value
user_preferences
id
item_result (foreign_key prefernce_id)
favorite_result (foreign_key preference_id)
recent_result (foreign_key preference_id)
I want something which will allow me to extract values like we do user.item.name
same way I want to do user_preference.item_result.value
I resolved the issue on my own..
Before posting answer I must say everyone should user rails console
I have define relations as follows
now I can access the values as
and other way around