title: Rails: checking modified fields
body: <p>First, I've generated scaffold called 'item'</p>
  
  <p>I'd like to check which fields of the item are modified. and I've tried two possible attempts, those're not work tho.</p>
  
  <p>First Attempt!</p>
  
  <pre><code>def edit
    @item = Item.find(params[:id])
    @item_before_update = @item.dup
  end
  
  def update
    @item = Item.find(params[:id])
    # compare @item_before_update and @item here, but @item_before_update is NIL !!!
  end
  </code></pre>
  
  <p>Second Attempt!
  I looked for the way passing data from view to controller and I couldn't.
  <em>edit.html.erb</em></p>
  
  <pre><code>&lt;% @item_before_update = @item.dup %&gt; # I thought @item_before_update can be read in update method of item controller. But NO.
  &lt;% params[:item_before_update] = @item.dup %&gt; # And I also thought params[:item_before_update] can be read in update mothod of item controller. But AGAIN NO
  
  &lt;% form_for(@item) do |f| %&gt;
  # omitted
  &lt;% end %&gt;
  </code></pre>
  
  <p>Please let me know how to solve this problem :(</p>