Skip to content
This repository
Browse code

Correctly handle non-existent pages as 404

  • Loading branch information...
commit 49fd9951e35678d9a7da9f6d3230d3a0d42d44b5 1 parent c461797
Gray Manley authored April 22, 2012
8  app/controllers/albums_controller.rb
@@ -2,7 +2,7 @@ class AlbumsController < ApplicationController
2 2
   respond_to :html, :json, :js
3 3
 
4 4
   def show
5  
-    @album = Album.find_by_slug(params[:id])
  5
+    @album = Album.find_by_slug!(params[:id])
6 6
     @images = @album.images.page(params[:page]).per(100)
7 7
     authorize!(:show, @album)
8 8
 
@@ -17,7 +17,7 @@ def new
17 17
   end
18 18
 
19 19
   def edit
20  
-    @album = Album.find_by_slug(params[:id])
  20
+    @album = Album.find_by_slug!(params[:id])
21 21
     authorize!(:edit, @album)
22 22
 
23 23
     respond_with(@album)
@@ -32,7 +32,7 @@ def create
32 32
   end
33 33
 
34 34
   def update
35  
-    @album = Album.find_by_slug(params[:id])
  35
+    @album = Album.find_by_slug!(params[:id])
36 36
     authorize!(:update, @album)
37 37
 
38 38
     @album.update_attributes(params[:album])
@@ -40,7 +40,7 @@ def update
40 40
   end
41 41
 
42 42
   def destroy
43  
-    @album = Album.find_by_slug(params[:id])
  43
+    @album = Album.find_by_slug!(params[:id])
44 44
     authorize!(:destroy, @album)
45 45
 
46 46
     @album.destroy
8  app/controllers/categories_controller.rb
@@ -9,7 +9,7 @@ def index
9 9
   end
10 10
 
11 11
   def show
12  
-    @category = Category.find_by_slug(params[:id])
  12
+    @category = Category.find_by_slug!(params[:id])
13 13
     @children = @category.children.accessible_by(current_ability)
14 14
     authorize!(:show, @category)
15 15
 
@@ -24,7 +24,7 @@ def new
24 24
   end
25 25
 
26 26
   def edit
27  
-    @category = Category.find_by_slug(params[:id])
  27
+    @category = Category.find_by_slug!(params[:id])
28 28
     authorize!(:edit, @category)
29 29
 
30 30
     respond_with(@category)
@@ -39,7 +39,7 @@ def create
39 39
   end
40 40
 
41 41
   def update
42  
-    @category = Category.find_by_slug(params[:id])
  42
+    @category = Category.find_by_slug!(params[:id])
43 43
     authorize!(:update, @category)
44 44
 
45 45
     @category.update_attributes(params[:category])
@@ -47,7 +47,7 @@ def update
47 47
   end
48 48
 
49 49
   def destroy
50  
-    @category = Category.find_by_slug(params[:id])
  50
+    @category = Category.find_by_slug!(params[:id])
51 51
     authorize!(:destroy, @category)
52 52
 
53 53
     @category.destroy
4  app/controllers/images_controller.rb
@@ -2,7 +2,7 @@ class ImagesController < ApplicationController
2 2
   respond_to :js, :json
3 3
 
4 4
   def create
5  
-    @album = Album.find_by_slug(params[:album_id])
  5
+    @album = Album.find_by_slug!(params[:album_id])
6 6
     @image = @album.images.new(params[:image])
7 7
     authorize!(:create, @image)
8 8
 
@@ -11,7 +11,7 @@ def create
11 11
   end
12 12
 
13 13
   def destroy
14  
-    @album = Album.find_by_slug(params[:album_id])
  14
+    @album = Album.find_by_slug!(params[:album_id])
15 15
     @image = @album.images.find(params[:id])
16 16
     authorize!(:destroy, @image)
17 17
 

0 notes on commit 49fd995

Please sign in to comment.
Something went wrong with that request. Please try again.