|
|
|
@@ -4,7 +4,7 @@ class CategoriesController < ApplicationController |
|
|
|
# GET /categories |
|
|
|
# GET /categories.json |
|
|
|
def index |
|
|
|
@categories = Category.all |
|
|
|
@categories = User.find(session[:user_id]).categories |
|
|
|
end |
|
|
|
|
|
|
|
# GET /categories/1 |
|
|
|
@@ -30,7 +30,7 @@ class CategoriesController < ApplicationController |
|
|
|
|
|
|
|
respond_to do |format| |
|
|
|
if @category.save |
|
|
|
format.html { redirect_to @category, notice: 'Category was successfully created.' } |
|
|
|
format.html { redirect_to :categories, notice: 'Category was successfully created.' } |
|
|
|
format.json { render :show, status: :created, location: @category } |
|
|
|
else |
|
|
|
format.html { render :new } |
|
|
|
@@ -56,10 +56,13 @@ class CategoriesController < ApplicationController |
|
|
|
# DELETE /categories/1 |
|
|
|
# DELETE /categories/1.json |
|
|
|
def destroy |
|
|
|
@category.destroy |
|
|
|
respond_to do |format| |
|
|
|
format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' } |
|
|
|
format.json { head :no_content } |
|
|
|
if @category.destroy |
|
|
|
respond_to do |format| |
|
|
|
format.html { redirect_to categories_url, notice: 'Category was successfully destroyed.' } |
|
|
|
format.json { head :no_content } |
|
|
|
end |
|
|
|
else |
|
|
|
redirect_to categories_url, notice: @category.errors.full_messages.first |
|
|
|
end |
|
|
|
end |
|
|
|
|
|
|
|
|