From b24bfb62e64643929894f06d943aeb94428ba3e7 Mon Sep 17 00:00:00 2001 From: Nick Quaranto Date: Mon, 15 Sep 2008 22:28:23 -0400 Subject: [PATCH] Unfroze old Rails version and moved to Rails 2.1.1. Fixed up a few issues with posts and admin posts controller. All tests are passing, too! --- .gitignore | 3 ++- app/controllers/admin/posts_controller.rb | 6 +++--- app/controllers/posts_controller.rb | 6 +++++- config/environments/development.rb | 1 - 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/.gitignore b/.gitignore index 45274ff..a14cab0 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,8 @@ config/defensio.yml .DS_Store ./**/.DS_Store Capfile +*.tmproj public/cache public/cache/** public/javascripts/all.js -public/stylesheets/all.css \ No newline at end of file +public/stylesheets/all.css diff --git a/app/controllers/admin/posts_controller.rb b/app/controllers/admin/posts_controller.rb index f43390c..4b19845 100644 --- a/app/controllers/admin/posts_controller.rb +++ b/app/controllers/admin/posts_controller.rb @@ -23,7 +23,7 @@ def index # GET /posts/1.xml def show @post = Post.find_by_permalink(params[:id], :include => :comments) || Post.find(params[:id]) - redirect_to '/' and return unless @post.type.match(/Article|Snippet/) + redirect_to admin_posts_path and return unless @post.type.match(/Article|Snippet/) @comment = flash[:comment] || @post.comments.build respond_to do |format| format.html # show.html.erb @@ -55,7 +55,7 @@ def create respond_to do |format| if @post.save flash[:notice] = 'Post was successfully created.' - format.html { redirect_to @post.link } + format.html { redirect_to admin_post_path(@post) } format.xml { render :xml => @post, :status => :created, :location => @post } else flash[:error] = @post.errors.full_messages @@ -74,7 +74,7 @@ def update if @post.update_attributes(params[:post]) expire_fragment(@post.permalink) flash[:notice] = 'Post was successfully updated.' - format.html { redirect_to @post.link } + format.html { redirect_to admin_post_path(@post) } format.js { render :json => @post } format.xml { head :ok } else diff --git a/app/controllers/posts_controller.rb b/app/controllers/posts_controller.rb index a08f1ce..4c61bbe 100644 --- a/app/controllers/posts_controller.rb +++ b/app/controllers/posts_controller.rb @@ -34,7 +34,11 @@ def show private def post_repo @post_type = params[:posts_type] || request.path.gsub(POST_TYPE_PATTERN, '\1') - return @post_type.classify.constantize + + # for some reason '/' this gets classified as '::', which is an Object. Adding a check for that. + throw NameError if @post_type.eql?('/') + + return @post_type.classify.constantize rescue => e logger.info(e) @post_type = 'posts' diff --git a/config/environments/development.rb b/config/environments/development.rb index 09a451f..85c9a60 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -12,7 +12,6 @@ config.action_controller.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false -config.action_view.cache_template_extensions = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false \ No newline at end of file