I found this on the ransack github repository:
def ransackable_attributes(auth_object = nil)
column_names + _ransackers.keys
end
So in my model, I can override this method by just doing something different.
def self.ransackable_attributes(auth_object = nil)
column_names.unshift(column_names.delete('name', 'role')) - ['id', 'first_name', 'middle_name', 'last_name', 'created_at', 'updated_at', 'encrypted_password', 'reset_password_token', 'reset_password_sent_at', 'remember_created_at',
'sign_in_count', 'current_sign_in_at', 'last_sign_in_at', 'current_sign_in_ip', 'last_sign_in_ip']+ _ransackers.keys
end
Since column_names
is just an array, I can remove an element from the array, then add it with unshift
. If someone has a better solution, please still post it here.