Fix bug in boards load and destroy belonging posts when destroying board

This commit is contained in:
riggraz
2019-09-19 18:55:55 +02:00
parent 2bc991e154
commit 98b8d53ad0
2 changed files with 3 additions and 1 deletions

View File

@@ -10,6 +10,6 @@ class ApplicationController < ActionController::Base
end
def load_boards
@boards = Board.all.only(:id, :name)
@boards = Board.select(:id, :name).order(order: :asc)
end
end

View File

@@ -1,4 +1,6 @@
class Board < ApplicationRecord
has_many :posts, dependent: :destroy
after_initialize :set_order_to_last
validates :name, presence: true, uniqueness: true