Sha256: 84b15e7d94604e9cc5a119a821eb27833c406727baabe34c7e57f81272efe455
Contents?: true
Size: 1.46 KB
Versions: 3
Compression:
Stored size: 1.46 KB
Contents
require_dependency "expense_gun/application_controller" module ExpenseGun class ExpenseLinesController < ApplicationController before_action :set_objects def index redirect_to expense_path(@expense) end def new authorize! :edit, @expense @expense_line = @expense.expense_lines.new end def create authorize! :edit, @expense @expense_line = @expense.expense_lines.new(expense_line_params) if @expense_line.save flash[:success] = t("expense_gun.expense_line.flash.created") redirect_to expense_path(@expense) else render :new end end def edit authorize! :edit, @expense end def update authorize! :edit, @expense if @expense_line.update_attributes(expense_line_params) flash[:success] = t("expense_gun.expense_line.flash.created") redirect_to expense_path(@expense) else render :edit end end def destroy authorize! :edit, @expense @expense_line.destroy flash[:success] = t("expense_gun.expense_line.flash.created") redirect_to expense_path(@expense) end private def set_objects @expense = Expense.find params[:expense_id] @expense_line = ExpenseLine.find params[:id] if params[:id].present? end def expense_line_params params.require(:expense_line).permit! end end end
Version data entries
3 entries across 3 versions & 1 rubygems