summaryrefslogtreecommitdiff
path: root/app/controllers/characters/item_infixes_controller.rb
blob: 0b5f1c5b3a0471210198c4d6f7c373b3a124dcc7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
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