I have two types of users; normal user and admin.
I have a field called priority in the table task.
This priority field is invisible to the normal user, but not to the
admin. The admin has to fill in the priority field when he adds a record
via filling a form. Thus, i need to add validates_presence_of :priority
to the model task. But, if i do this, then the normal user can’t add a
record to the task as he will fail the validation.
One way i can think of is for the normal user controller to fill in the
priority value before the record is saved to pass the validation. Then,
the priority field is edited to null / empty after the record has been
saved saved.
I dont like this solution. What’s a better way of doing this?
Some of the user management frameworks add a method such as
User.current_user to be able to easily get the currently logged in user.
If
you have that you’re problem solves itself:
Some of the user management frameworks add a method such as
User.current_user to be able to easily get the currently logged in user.
If
you have that you’re problem solves itself: