class Characters::ItemInfixesController < ApplicationController def create # TODO: Can this find-by-id happen automagically? @item_infix = current_char.infix(Item.find(params[:item_id]), Skill.find(params[:skill_id])) if @item_infix flash[:notice] = "Infixed #{@item_infix.item.name}." else flash[:alert] = "Failed to infix item." end redirect_to character_skills_path(current_char) end def destroy @item_infix = ItemInfix.find(params[:id]) if current_char.remove_infix(@item_infix) flash[:notice] = "Removed #{@item_infix.item.name}." else flash[:alert] = "Failed to remove #{@item_infix.item.name}." end redirect_to character_skills_path(current_char) end private def item_infix_params params.require(:item_infix).permit(:item_id, :skill_id) end end