Permalink
Browse files

Correctly handle non-existent pages as 404

  • Loading branch information...
1 parent c461797 commit 49fd9951e35678d9a7da9f6d3230d3a0d42d44b5 @gmanley committed Apr 23, 2012
View
8 app/controllers/albums_controller.rb
@@ -2,7 +2,7 @@ class AlbumsController < ApplicationController
respond_to :html, :json, :js
def show
- @album = Album.find_by_slug(params[:id])
+ @album = Album.find_by_slug!(params[:id])
@images = @album.images.page(params[:page]).per(100)
authorize!(:show, @album)
@@ -17,7 +17,7 @@ def new
end
def edit
- @album = Album.find_by_slug(params[:id])
+ @album = Album.find_by_slug!(params[:id])
authorize!(:edit, @album)
respond_with(@album)
@@ -32,15 +32,15 @@ def create
end
def update
- @album = Album.find_by_slug(params[:id])
+ @album = Album.find_by_slug!(params[:id])
authorize!(:update, @album)
@album.update_attributes(params[:album])
respond_with(@album)
end
def destroy
- @album = Album.find_by_slug(params[:id])
+ @album = Album.find_by_slug!(params[:id])
authorize!(:destroy, @album)
@album.destroy
View
8 app/controllers/categories_controller.rb
@@ -9,7 +9,7 @@ def index
end
def show
- @category = Category.find_by_slug(params[:id])
+ @category = Category.find_by_slug!(params[:id])
@children = @category.children.accessible_by(current_ability)
authorize!(:show, @category)
@@ -24,7 +24,7 @@ def new
end
def edit
- @category = Category.find_by_slug(params[:id])
+ @category = Category.find_by_slug!(params[:id])
authorize!(:edit, @category)
respond_with(@category)
@@ -39,15 +39,15 @@ def create
end
def update
- @category = Category.find_by_slug(params[:id])
+ @category = Category.find_by_slug!(params[:id])
authorize!(:update, @category)
@category.update_attributes(params[:category])
respond_with(@category)
end
def destroy
- @category = Category.find_by_slug(params[:id])
+ @category = Category.find_by_slug!(params[:id])
authorize!(:destroy, @category)
@category.destroy
View
4 app/controllers/images_controller.rb
@@ -2,7 +2,7 @@ class ImagesController < ApplicationController
respond_to :js, :json
def create
- @album = Album.find_by_slug(params[:album_id])
+ @album = Album.find_by_slug!(params[:album_id])
@image = @album.images.new(params[:image])
authorize!(:create, @image)
@@ -11,7 +11,7 @@ def create
end
def destroy
- @album = Album.find_by_slug(params[:album_id])
+ @album = Album.find_by_slug!(params[:album_id])
@image = @album.images.find(params[:id])
authorize!(:destroy, @image)

0 comments on commit 49fd995

Please sign in to comment.