<commit_before>class AlbumsController < ApplicationController
  before_action :set_album, only: [:show, :edit, :update, :destroy]
  
  def show
  end

  def edit
  end

  def new
    @family = Family.friendly.find(params[:id])
    @album = Album.new
    @photo = Photo.new
  end

  def create
    album = Album.new(album_params)
    album.permissions = album.parse_permission(params[:album][:parse_permission])
    album.family_id = get_id_from_slug(params[:id])
    album.save
    current_person.albums << album
    redirect_to album_path(Family.friendly.find(params[:id]), album)
  end

  def update
    @album.update(album_params)

    if @album.save
      redirect_to albums_path(@family, @album), :notice => "User successfully edited"
    else
      render 'form' 
      flash[:alert] = "Sorry, could not update."
    end
  end

  def destroy
    respond_to do |f|
      if current_person == @album.owner
        @album.destroy
        f.html {redirect_to albums_path}
        f.js {render 'destroy', locals: {album: @album, family: @family}}
      else
        @msg = "Sorry, you do not own this album."
        f.js {render 'destroy_failure', locals: {msge: @msg}}
      end
    end
  end

  def index
    @albums = current_person.albums
  end

  private

  def set_album
    @family = Family.friendly.find(params[:id])
    @album = Album.find(params[:album_id])
  end

  def album_params
    params.require(:album).permit(:name, :family_id)
  end<commit_msg>replaced the permitted albums method<commit_after>class AlbumsController < ApplicationController
  before_action :set_album, only: [:show, :edit, :update, :destroy]
  
  def show
  end

  def edit
  end

  def new
    @family = Family.friendly.find(params[:id])
    @album = Album.new
    @photo = Photo.new
  end

  def create
    album = Album.new(album_params)
    album.permissions = album.parse_permission(params[:album][:parse_permission])
    album.family_id = get_id_from_slug(params[:id])
    album.save
    current_person.albums << album
    redirect_to album_path(Family.friendly.find(params[:id]), album)
  end

  def update
    @album.update(album_params)

    if @album.save
      redirect_to albums_path(@family, @album), :notice => "User successfully edited"
    else
      render 'form' 
      flash[:alert] = "Sorry, could not update."
    end
  end

  def destroy
    respond_to do |f|
      if current_person == @album.owner
        @album.destroy
        f.html {redirect_to albums_path}
        f.js {render 'destroy', locals: {album: @album, family: @family}}
      else
        @msg = "Sorry, you do not own this album."
        f.js {render 'destroy_failure', locals: {msge: @msg}}
      end
    end
  end

  def index
    @albums = current_person.permitted_albums
  end

  private

  def set_album
    @family = Family.friendly.find(params[:id])
    @album = Album.find(params[:album_id])
  end

  def album_params
    params.require(:album).permit(:name, :family_id)
  end
{'fraction_non_alphanumeric': 0.11197301854974705, 'fraction_numerical': 0.0, 'mean_word_length': 3.035374149659864, 'pattern_counts': {'":': 0, '<': 9, '<?xml version=': 0, '>': 5, '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': '4315216', 'n_tokens_mistral': 962, 'n_tokens_neox': 942, 'n_words': 239}