I am trying to get my user model to work in ActiveAdmin but it seems to only work when I refer the models back to the user model itself, which then breaks my forms in my app.
This way breaks my ActiveAdmin user view but by forms work in my app.
user.rb
class User < ApplicationRecord
# Include default devise modules. Others available are:
# :confirmable, :lockable, :timeoutable and :omniauthable
devise :database_authenticatable, :registerable,
:recoverable, :rememberable, :trackable, :validatable
has_many :vehicle
has_one :permit
has_one :faculty
has_one :emergency_contact
has_one :student
def admin?
roles == "admin"
end
def editor?
roles == "editor"
end
def standard?
roles == "standard"
end
end
user.rb
has_many :vehicle, class_name: 'User'
has_one :permit, class_name: 'User'
has_one :faculty, class_name: 'User'
has_one :emergency_contact, class_name: 'User'
has_one :student, class_name: 'User'
The second way is what gets my ActiveAdmin user view to work (I know this is wrong just don't know how to fix it) but it breaks my forms in my app. When ActiveAdmin is broken I am getting the error:
undefined method 'vehicle_id_eq' for Ransack::Search<class: User when I click on the users view in ActiveAdmin.
Anyone have any ideas on what I can do to fix my model to get ActiveAdmin to work properly?
Edit**
admin/user.rb
ActiveAdmin.register User do
permit_params :roles
end
models/vehicle.rb
class Vehicle < ApplicationRecord
belongs_to :user
end