Sha256: 67f77c350c2404fde9083df4d17668a74157f8c240fd2e050730b552908c9cda
Contents?: true
Size: 1.23 KB
Versions: 1
Compression:
Stored size: 1.23 KB
Contents
require 'active_record/fixtures' require 'find' require 'base64' module RailsSandboxServer class SandboxController < ActionController::Base rescue_from StandardError do |exception| puts exception puts exception.backtrace render text: exception, status: 500 end def setup fixtures = Array.wrap(params[:fixture] || params[:fixtures]) path = params[:fixtures_dir] || fixture_path class_mapping = params[:mapping] || {} class_mapping.each do |k, v| class_mapping[k] = v.classify.constantize end ActiveRecord::FixtureSet.create_fixtures(path, fixtures, class_mapping) render text: 'fixture load successfully' end def rollback logger.info "rollback transaction #{ActiveRecord::Base.connection.current_transaction}" ActiveRecord::Base.connection.rollback_transaction ActiveRecord::FixtureSet.reset_cache Rails.cache.clear render text: 'rollback successfully' end def execute code = Base64.decode64(params[:code]) result = eval(code) render text: result end private def fixture_path Rails.root.join(Rails.configuration.rails_sandbox_server.fixture_path || 'test/fixtures') end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
rails_sandbox_server-0.0.2 | app/controllers/rails_sandbox_server/sandbox_controller.rb |