<commit_before>module Alchemy
	module Admin
		class ResourcesController < Alchemy::Admin::BaseController

			include Alchemy::ResourcesHelper
			helper Alchemy::ResourcesHelper
			helper_method :resource_handler

			rescue_from Exception, :with => :exception_handler

			before_filter :load_resource, :only => [:show, :edit, :update, :destroy]


			def index
				if params[:query].blank?
					items = resource_handler.model
				else
					search_terms = ActiveRecord::Base.sanitize("%#{params[:query]}%")
					items = resource_handler.model.where(resource_handler.searchable_attributes.map { |attribute|
						"`#{resource_handler.namespaced_model_name.pluralize}`.`#{attribute[:name]}` LIKE #{search_terms}"
					}.join(" OR "))
				end
				instance_variable_set("@#{resource_handler.resources_name}", items.page(params[:page] || 1).per(per_page_value_for_screen_size))
			end

			def new
				instance_variable_set("@#{resource_handler.model_name}", resource_handler.model.new)
				render :layout => !request.xhr?
			end

			def show
				render :layout => !request.xhr?
			end

			def edit
				render :layout => !request.xhr?
			end

			def create
				instance_variable_set("@#{resource_handler.model_name}", resource_handler.model.new(params[resource_handler.namespaced_model_name.to_sym]), :as => current_user.role.to_sym)
				resource_instance_variable.save
				render_errors_or_redirect(
						resource_instance_variable,
						resources_path,
						flash_notice_for_resource_action
				)<commit_msg>fixed :as-syntax for mass-assignment-protection<commit_after>module Alchemy
	module Admin
		class ResourcesController < Alchemy::Admin::BaseController

			include Alchemy::ResourcesHelper
			helper Alchemy::ResourcesHelper
			helper_method :resource_handler

			rescue_from Exception, :with => :exception_handler

			before_filter :load_resource, :only => [:show, :edit, :update, :destroy]


			def index
				if params[:query].blank?
					items = resource_handler.model
				else
					search_terms = ActiveRecord::Base.sanitize("%#{params[:query]}%")
					items = resource_handler.model.where(resource_handler.searchable_attributes.map { |attribute|
						"`#{resource_handler.namespaced_model_name.pluralize}`.`#{attribute[:name]}` LIKE #{search_terms}"
					}.join(" OR "))
				end
				instance_variable_set("@#{resource_handler.resources_name}", items.page(params[:page] || 1).per(per_page_value_for_screen_size))
			end

			def new
				instance_variable_set("@#{resource_handler.model_name}", resource_handler.model.new)
				render :layout => !request.xhr?
			end

			def show
				render :layout => !request.xhr?
			end

			def edit
				render :layout => !request.xhr?
			end

			def create
				instance_variable_set("@#{resource_handler.model_name}", resource_handler.model.new(params[resource_handler.namespaced_model_name.to_sym], :as => current_user.role.to_sym))
				resource_instance_variable.save
				render_errors_or_redirect(
						resource_instance_variable,
						resources_path,
						flash_notice_for_resource_action
				)
{'fraction_non_alphanumeric': 0.11439842209072978, 'fraction_numerical': 0.0006574621959237344, 'mean_word_length': 4.68785046728972, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 15, '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': '4436465', 'n_tokens_mistral': 1146, 'n_tokens_neox': 918, 'n_words': 157}