class Admin::PostsController

Public Instance Methods

create() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 19
def create
  @post = @mailing_list.posts.build(params[:post])
  if @post.save
    flash[:notice] = "Created #{@post.subject}"
    redirect_to edit_admin_mailing_list_post_path(@mailing_list, @post)
  else
    render :edit
  end
end
destroy() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 53
def destroy
  @post = Post.find(params[:id])
  unless @post.destroy
    flash[:notice] = "Could not delete #{@post.subject}"
  end
  redirect_to admin_mailing_list_posts_path(@mailing_list)
end
edit() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 39
def edit
  @post = Post.find(params[:id])
end
index() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 6
def index
  @posts = Post.paginate(
    :order => "date desc", 
    :page => params[:page],
    :conditions => [ "mailing_list_id = ?", @mailing_list.id ]
  )
end
new() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 14
def new
  @post = @mailing_list.posts.build
  render :edit
end
receive() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 29
def receive
  @post = MailingListMailer.receive(params[:raw].read.encode("UTF-8"))
  if @post.save
    flash[:notice] = "Created #{@post.subject}"
    redirect_to admin_mailing_list_posts_path(@mailing_list)
  else
    render :edit
  end
end
update() click to toggle source
# File app/controllers/admin/posts_controller.rb, line 43
def update
  @post = Post.find(params[:id])
  if @post.update_attributes(params[:post])
    flash[:notice] = "Updated #{@post.subject}"
    redirect_to edit_admin_mailing_list_post_path(@mailing_list, @post)
  else
    render :edit
  end
end