-
Notifications
You must be signed in to change notification settings - Fork 2
Not–so–skinny Controllers
cavalle edited this page Dec 24, 2012
·
1 revision
- https://gist.github.com/2838490#gistcomment-356060
- https://twitter.com/dhh/status/216234613507489792
class PostsController
before_filter :set_entry
before_filter :reject_spam
def create
@comment = @entry.comments.create!(params[:post].permit(:title, :body).merge(author: current_user))
Notifications.new_comment(@comment).deliver
TwitterPoster.new(current_user, @comment.body).post if @comment.share_on_twitter?
FacebookPoster.new(current_user, @comment.body).action(:comment) if @comment.share_on_facebook?
end
private
def set_entry
@entry = current_account.entries.find(params[:id])
end
def reject_spam
head :bad_request if SpamChecker.spammy?(params[:post][:body])
end
end