Skip to content

Commit

Permalink
Unfroze old Rails version and moved to Rails 2.1.1. Fixed up a few is…
Browse files Browse the repository at this point in the history
…sues with posts and admin posts controller. All tests are passing, too!
  • Loading branch information
qrush committed Sep 16, 2008
1 parent a3c1536 commit b24bfb6
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -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
public/stylesheets/all.css
6 changes: 3 additions & 3 deletions app/controllers/admin/posts_controller.rb
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 5 additions & 1 deletion app/controllers/posts_controller.rb
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion config/environments/development.rb
Expand Up @@ -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

0 comments on commit b24bfb6

Please sign in to comment.