Reputation: 53
I'm creating an app where I need to check kids in. I'm stuck on a particular section, which I'm sure is really easy. Might just be overthinking it.
I have a page with an input field and a submit button. I want to be able to input a kid's ID and on submit I want the database column, "status", to be changed to either true or false (depending on what is it).
Just looking for some tips to get me in the right direction. Thanks in advance! LP
Upvotes: 0
Views: 57
Reputation: 4606
You can use ActiveRecord callbacks
For example you can define a before_save or before_create callback like this:
before_create :load_status
private
def load_status
self.status = !self.identifier.blank? #self.identifier is the kid's ID
end
So, if kid's ID has some value the status attribute will be true
Upvotes: 1