Sha256: 9c747b9cc303fcc761b01a1ac20aa61e788970800d0e061a63403e24e2dd43a7
Contents?: true
Size: 1.37 KB
Versions: 5
Compression:
Stored size: 1.37 KB
Contents
class PingController < ApplicationController layout nil # This implements trackback functionality for other people tracking back to # our elite journal. This method should have a post id passed in the url and # the following are posted: # title # excerpt # url # blog_name # Url is the only field we'll require, and we'll use that for title if title # isn't passed in. # # Errors that we'll spew back in the faces of those unelite enough to send us garbage: # 1 - They didn't send an ID or a URL, both are required. # 2 - They tried to trackback to a BS post number. # 3 - For whatever damn reason, the trackback didn't save in the db. Gnomes. def trackback @error = '0' @message = nil unless @params['id'] and @params['url'] @error = '1' @message = 'Parameters missing.' return end begin post = Post.find(@params['id']) ping = post.build_to_pings ping.title = @params['title'] || @params['url'] ping.excerpt = @params['excerpt'] || '' ping.url = @params['url'] ping.blog_name = @params['blog_name'] || '' unless ping.save @error = '3' @message = 'TrackBack Ping not saved.' end rescue ActiveRecord::RecordNotFound, ActiveRecord::StatementInvalid @error = '2' @message = 'Post not found.' end end end
Version data entries
5 entries across 5 versions & 1 rubygems