Sha256: 5c3575bffdda4247a167fb8b1b6bdf5e98f80fe35c0051e2326cb7482b68778a

Contents?: true

Size: 744 Bytes

Versions: 2

Compression:

Stored size: 744 Bytes

Contents

require 'track_changes'

class PostsController < ApplicationController
  include TrackChanges
  before_filter :find_post
  track_changes :post

  def show
    render :text => @post.inspect
  end

  # PUT /posts/1
  # PUT /posts/1.xml
  def update
    respond_to do |format|
      if @post.update_attributes(params[:post])
        flash[:notice] = 'Post was successfully updated.'
        format.html { redirect_to(@post) }
        format.xml  { head :ok }
      else
        format.html { render :action => "edit" }
        format.xml  { render :xml => @post.errors, :status => :unprocessable_entity }
      end
    end
  end

  protected

  def current_user
    "John Smith"
  end

  def find_post
    @post = Post.find(params[:id])
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
track_changes-0.4.1 test/rails_root/app/controllers/posts_controller.rb
track_changes-0.4.0 test/rails_root/app/controllers/posts_controller.rb