Reputation: 1734
I installed Ruby on Rails Gem Active Admin
and made association between tables.
Category
with fields (category_name:string)
with
SubCategory
with fields (sub_category_name:string, category_id:integer)
but when i view admin console for subcategory in drop down for categories instead of their name encrypted string is coming which refers to category id. Its like:
#<Category:0x698a648>
#<Category:0x6958998>
I want category name to be here. I know def to_s
function can do it but in active admin gem i am not sure where to write this function.
Any Idea will be highly appreciated..
Upvotes: 2
Views: 1446
Reputation: 30803
You could code the to_s method in the class and return the category name:
#app/models/category.rb
class Category
#...
def to_s
category_name
end
end
Upvotes: 2