<commit_before>module Candela
  module ControllerAdditions
    def self.authorize_resource(controller_class, opts)
      controller_name = controller_class.controller_name
      instance_name = controller_name.singularize 

      controller_class.prepend_before_filter do |controller|
        params = controller.params
        model = params[:controller].classify.constantize

        case params[:action].to_sym
        when :new
          controller.instance_variable_set("@#{instance_name}", model.new)
        when :show, :edit
          controller.instance_variable_set("@#{instance_name}", model.find(params[:id]))
        end
      end
    end
  end
end
<commit_msg>Handle the #create action in authorize_resource<commit_after>module Candela
  module ControllerAdditions
    def self.authorize_resource(controller_class, opts)
      controller_name = controller_class.controller_name
      instance_name = controller_name.singularize 

      controller_class.prepend_before_filter do |controller|
        params = controller.params
        model = params[:controller].classify.constantize

        case params[:action].to_sym
        when :new
          controller.instance_variable_set("@#{instance_name}", model.new)
        when :create
          created_instance = model.new(controller.send(opts[:params]))
          controller.instance_variable_set("@#{instance_name}", created_instance)
        when :show, :edit
          controller.instance_variable_set("@#{instance_name}", model.find(params[:id]))
        end
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08740359897172237, 'fraction_numerical': 0.0, 'mean_word_length': 3.3491620111731844, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '229984', 'n_tokens_mistral': 413, 'n_tokens_neox': 408, 'n_words': 79}