Created
January 11, 2013 19:12
-
-
Save aneziocampos/4513145 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
before_filter :authenticate_user! | |
before_filter :load_post_and_project, except: :create | |
def publish | |
@post.publish! | |
default_respond_to | |
end | |
def mark_as_spam | |
@post.spam! | |
default_respond_to | |
end | |
private | |
def load_post_and_project | |
@post = current_user.administrable_posts.find(params[:id]) | |
@project = @post.project | |
end | |
def default_respond_to | |
respond_to do |format| | |
format.html { redirect_to project_path(@project) } | |
format.js | |
end | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PostsController < ApplicationController | |
before_filter :authenticate_user! | |
before_filter :load_post_and_project, except: :create | |
respond_to :html, :js | |
def create | |
@post = current_user.posts.new(params[:post]) | |
@post.save | |
@project = @post.project | |
if @project.user == current_user | |
@post.approve! | |
@post.ancestors.map { |ancestor| ancestor.approve! unless ancestor.approved? } | |
end | |
respond_with(@project) | |
end | |
def publish | |
@post.publish! | |
respond_with(@project) | |
end | |
def mark_as_spam | |
@post.spam! | |
respond_with(@project) | |
end | |
private | |
def load_post_and_project | |
@post = current_user.administrable_posts.find(params[:id]) | |
@project = @post.project | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment