Hi all,
I hv the following model:
class User < ActiveRecord::Base has_and_belongs_to_many :roles
def user_role self.roles end end
class Role < ActiveRecord::Base has_and_belongs_to_many :users end
When I run the following code: user = User.find(:first) user.to_json
there's no user_role attribute displayed. but when I run user.user_role, it can give the expected result. So, how can I get the associated attribute when using to_json ?
Appreciate for your help.