Created
January 30, 2019 10:16
-
-
Save salami-art/c69d48a78406dff6159ac5566540badf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Font < ApplicationRecord | |
has_many :styles_fonts | |
has_many :styles, through: :styles_fonts | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Style < ApplicationRecord | |
has_many :styles_fonts, -> { distinct }, dependent: :destroy | |
has_many :fonts, -> { distinct }, through: :styles_fonts | |
accepts_nested_attributes_for :fonts | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::StylesController < Admin::BaseController | |
def delete_font | |
@style = Style.find(params[:id]) | |
@style.fonts.delete params[:font_id] # ActiveRecord::ActiveRecordError (delete_all doesn't support distinct): | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment