Added CRUD but edit and delete giving errors.
This commit is contained in:
parent
5c2466dfaf
commit
640e8d34ab
5 changed files with 54 additions and 5 deletions
|
|
@ -11,6 +11,7 @@ class Assistant < Sequel::Model
|
|||
def validate
|
||||
super
|
||||
errors.add(:name, 'must be present') if name.nil? || name.empty?
|
||||
errors.add(:run_command, 'must be present') if run_command.nil? || run_command.empty?
|
||||
end
|
||||
|
||||
# Optional: Add custom methods for common operations
|
||||
|
|
@ -18,7 +19,16 @@ class Assistant < Sequel::Model
|
|||
where(name: name).first
|
||||
end
|
||||
|
||||
def self.find_by_run_command(run_command)
|
||||
where(run_command: run_command).first
|
||||
end
|
||||
|
||||
def self.active
|
||||
where(active: true)
|
||||
end
|
||||
|
||||
# Helper to check if this is a new record
|
||||
def new?
|
||||
id.nil?
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue