My application is experiencing the following error:
undefined method 'user_id' for # If you want to use a RailsAdmin virtual field (= a field without corresponding instance method), you should declare 'formatted_value' in the field definition. field: user_id formatted_value {bindings [: object] .call_some_method} end
In the rails_admin.rb file I put the following:
config.model User do
list do
field :nome
field :email
field :tipo
field :status
field :nota
field :current_sign_in_at
field :last_sign_in_at
field :current_sign_in_ip
field :last_sign_in_ip
field :user_id do
default_value do
bindings[:view]._current_user.id
end
end
end
end
The schema.rb file has the following:
create_table "users", force: true do |t|
t.string "nome"
t.integer "tipo"
t.integer "status"
t.text "nota"
t.datetime "created_at"
t.datetime "updated_at"
t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false
t.string "reset_password_token"
t.datetime "reset_password_sent_at"
t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0, null: false
t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at"
t.inet "current_sign_in_ip"
t.inet "last_sign_in_ip"
end
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree