I have this model:
class User < ActiveRecord::Base
TYPE = {:admin => "Administrator", :owner => "Owner", :client => "Customer"}
# some codes here
end
When I run below code in rails console:
User::TYPE
Output:
{:admin => "Administrator", :owner => "owner", :client => "Customer"}
And when I add the code in controller:
User::TYPE
This is the output:
[
{
"user_types": {
"user": "Administrator",
"owner": "owner",
"client": "Customer"
}
},
{
"user_types": {
"user": "Administrator",
"owner": "owner",
"client": "Customer"
}
},
{
"user_types": {
"user": "Administrator",
"owner": "owner",
"client": "Customer"
}
}
]
And I only I need:
{
"user_types": {
"user": "Administrator",
"owner": "owner",
"client": "Customer"
}
What I am doing wrong here. I also tried User::TYPE
but I don't get the correct result.
Aucun commentaire:
Enregistrer un commentaire