<commit_before>class DonationsController < ApplicationController

  before_filter :login_required
  skip_before_filter :verify_authenticity_token
  resources_controller_for :donations, :only => :create

  def create
    self.resource = new_resource

    respond_to do |format|
      if resource.save
        format.js { render :action => "create" }
      else
        format.js { render :action => "new"}
      end
    end
  end
  
  protected

  def can_create?
    access_denied unless Donation.createable_by?(current_user)
  end

  def new_resource
    current_user.donations.new(params[:donation])
  end

  def find_resources
    current_user.donations.unpaid
  end
end
<commit_msg>idiomatic use of resources_controller with response_for<commit_after>class DonationsController < ApplicationController
  before_filter :login_required
  resources_controller_for :donations, :only => :create

  response_for :create do |format|
    if resource_saved?
      format.js
    else
      format.js { render :action => "new"}
    end
  end

  
  protected

  def can_create?
    access_denied unless Donation.createable_by?(current_user)
  end

  def new_resource
    current_user.donations.new(params[:donation])
  end

  def find_resources
    current_user.donations.unpaid
  end
end

{'fraction_non_alphanumeric': 0.06640625, 'fraction_numerical': 0.0, 'mean_word_length': 3.6079136690647484, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2257872', 'n_tokens_mistral': 394, 'n_tokens_neox': 382, 'n_words': 92}