Skip to content

Commit

Permalink
gave in and just added subclasses of PostsController and Admin::Posts…
Browse files Browse the repository at this point in the history
…Controller due to weirdnesses with dynamically added controllers
  • Loading branch information
nakajima committed Feb 3, 2009
1 parent 443df4c commit 0929f6a
Show file tree
Hide file tree
Showing 15 changed files with 28 additions and 31 deletions.
2 changes: 2 additions & 0 deletions app/controllers/admin/articles_controller.rb
@@ -0,0 +1,2 @@
class Admin::ArticlesController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/admin/gists_controller.rb
@@ -0,0 +1,2 @@
class Admin::GistsController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/admin/pictures_controller.rb
@@ -0,0 +1,2 @@
class Admin::PicturesController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/admin/quotes_controller.rb
@@ -0,0 +1,2 @@
class Admin::QuotesController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/admin/snippets_controller.rb
@@ -0,0 +1,2 @@
class Admin::SnippetsController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/admin/tweets_controller.rb
@@ -0,0 +1,2 @@
class Admin::TweetsController < Admin::PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/articles_controller.rb
@@ -0,0 +1,2 @@
class ArticlesController < PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/gists_controller.rb
@@ -0,0 +1,2 @@
class GistsController < PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/pictures_controller.rb
@@ -0,0 +1,2 @@
class PicturesController < PostsController
end
15 changes: 4 additions & 11 deletions app/controllers/posts_controller.rb
@@ -1,21 +1,14 @@
class PostsController < Application
include SingleControllerInheritance

@@subtypes = []
cattr_reader :subtypes # Used by feeds_controller to calculate cache expirations.

# Used by feeds_controller to calculate cache expirations.
@@subtypes = [:articles, :links, :pictures, :quotes, :snippets, :tweets, :gists]
cattr_reader :subtypes

before_filter :redirect_to_admin, :if => :logged_in?

caches_page :index
caches_page :show

# Generates a new controller for each of these resources that will inherit
# from PostsController, with the block being called for each.
expose_as :articles, :links, :pictures, :quotes, :snippets, :tweets, :gists do |name|
subtypes << name
define_method(:post_type) { name }
end

# GET /posts
# GET /posts.xml
def index
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/quotes_controller.rb
@@ -0,0 +1,2 @@
class QuotesController < PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/snippets_controller.rb
@@ -0,0 +1,2 @@
class SnippetsController < PostsController
end
2 changes: 2 additions & 0 deletions app/controllers/tweets_controller.rb
@@ -0,0 +1,2 @@
class TweetsController < PostsController
end
1 change: 0 additions & 1 deletion config/environment.rb
Expand Up @@ -11,7 +11,6 @@
require File.join(File.dirname(__FILE__), 'boot')

require 'authenticated_model'
require 'single_controller_inheritance'

Rails::Initializer.run do |config|
config.load_paths += %W[
Expand Down
19 changes: 0 additions & 19 deletions lib/single_controller_inheritance.rb

This file was deleted.

0 comments on commit 0929f6a

Please sign in to comment.