<commit_before>class Admin::AssetContentsController < Admin::BaseController
  layout false

  before_filter :set_asset, :set_content
  helper :assets
  guards_permissions :asset, :manage => [:create, :destroy]

  def create
    @asset.contents << @content
    @asset.save
  end

  def destroy
    @asset.contents.delete @content
    @asset.save
  end

  private

    def set_asset
      @asset = @site.assets.find params[:asset_id]
    end

    def set_content
      key = params[:action] == 'create' ? :content_id : :id
      @content = ::Content.find params[key], :include => 'section'
      raise "no access" if @content.section.site_id != @site.id
    end

end<commit_msg>assets_contents create responds to js.<commit_after>class Admin::AssetContentsController < Admin::BaseController
  layout false

  before_filter :set_asset, :set_content
  helper :assets
  guards_permissions :asset, :manage => [:create, :destroy]

  def create
    @asset.contents << @content
    @asset.save
    
    respond_to do |format|
      format.js
    end
  end

  def destroy
    @asset.contents.delete @content
    @asset.save
  end

  private

    def set_asset
      @asset = @site.assets.find params[:asset_id]
    end

    def set_content
      key = params[:action] == 'create' ? :content_id : :id
      @content = ::Content.find params[key], :include => 'section'
      raise "no access" if @content.section.site_id != @site.id
    end

end
{'fraction_non_alphanumeric': 0.11025819958129798, 'fraction_numerical': 0.0, 'mean_word_length': 3.1807580174927113, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 7, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1220072', 'n_tokens_mistral': 455, 'n_tokens_neox': 439, 'n_words': 116}