Skip to content

Commit

Permalink
ensure solves are removed when averages are removed
Browse files Browse the repository at this point in the history
  • Loading branch information
justinj committed Oct 24, 2013
1 parent 99d3f61 commit fa9a468
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
4 changes: 4 additions & 0 deletions lib/model/average.rb
Expand Up @@ -8,6 +8,10 @@ class Average < Sequel::Model
many_to_one :competition
many_to_many :tags

def before_destroy
solves.each { |solve| solve.destroy }
super
end

def initialize(args={})
args[:visible] = false if args[:visible].nil?
Expand Down
1 change: 0 additions & 1 deletion routes/average.rb
Expand Up @@ -42,7 +42,6 @@
get "/average/delete_confirm/:id" do
authenticate!
@average = RCDB::Average.first(id: params[:id])
@average.remove_all_solves
@average.destroy
redirect "/average"
end
Expand Down

0 comments on commit fa9a468

Please sign in to comment.