repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/text_helpers.rb
lib/wizardly/wizard/text_helpers.rb
module Wizardly module Wizard module TextHelpers private def underscore_button_name(name) name.to_s.strip.squeeze(' ').gsub(/ /, '_').downcase end def button_name_to_symbol(str) underscore_button_name(str).to_sym end def symbol_to_button_name(sym) sym.to_s.gsub(/_/, ' ').squeeze(' ').titleize end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/page.rb
lib/wizardly/wizard/page.rb
require 'wizardly/wizard/text_helpers' module Wizardly module Wizard class Page include TextHelpers attr_reader :id, :title, :description attr_accessor :buttons, :fields def initialize(config, id, fields) @buttons = [] @title = symbol_to_button_name(id) @id = id @description = '' @fields = fields @config = config end def name; id.to_s; end def buttons_to(*args) buttons = @config.buttons @buttons = args.map do |button_id| raise(WizardConfigurationError, ":#{button_id} not defined as a button id in :button_to() call", caller) unless buttons.key?(button_id) buttons[button_id] end end def title_to(name) @title = name.strip.squeeze(' ') end def description_to(name) @description = name.strip.squeeze(' ') end end class PageField attr_reader :name, :column_type def initialize(name, type) @name = name @column_type = type.to_sym @field_type = nil end def field_type @field_type ||= case @column_type when :string then :text_field when :password then :password_field when :enum then :enum_select when :text then :text_area when :boolean then :check_box when :integer, :float, :decimal then :text_field when :datetime, :timestamp, :time then :datetime_select when :date then :date_select else :text_field end end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/utils.rb
lib/wizardly/wizard/utils.rb
module Wizardly module Wizard module Utils def self.formatted_redirect(r) return(nil) unless r r.is_a?(Hash)? r : "'#{r}'" end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/button.rb
lib/wizardly/wizard/button.rb
require 'wizardly/wizard/text_helpers' module Wizardly module Wizard class Button include TextHelpers attr_reader :name attr_reader :id def initialize(id, name=nil) @id = id @name = name || symbol_to_button_name(id) @user_defined = false end def user_defined?; @user_defined; end #used in the dsl def name_to(name, opts={}) case name when String then @name = name.strip.squeeze(' ') when Symbol then @name = symbol_to_button_name(name) end @id = opts[:id] if (opts[:id] && opts[:id].is_a?(Symbol)) end end class UserDefinedButton < Button def initialize(id, name=nil) super @user_defined = true end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/dsl.rb
lib/wizardly/wizard/dsl.rb
module Wizardly module Wizard class DSL def initialize(config) @config = config end # DSL methods def when_completed_redirect_to(redir); @config._when_completed_redirect_to(redir); end def when_canceled_redirect_to(redir); @config._when_canceled_redirect_to(redir); end def change_button(name) @config._change_button(name) end def create_button(name, opts) @config._create_button(name, opts) end def set_page(name); @config._set_page(name) end def mask_passwords(passwords) @config._mask_passwords(passwords) end alias_method :mask_password, :mask_passwords end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/configuration.rb
lib/wizardly/wizard/configuration.rb
require 'wizardly/wizard/utils' require 'wizardly/wizard/dsl' require 'wizardly/wizard/button' require 'wizardly/wizard/page' require 'wizardly/wizard/configuration/methods' module Wizardly module Wizard class Configuration include TextHelpers attr_reader :pages, :completed_redirect, :canceled_redirect, :controller_path, :controller_class_name, :controller_name, :page_order #enum_attr :persistance, %w(sandbox session database) def initialize(controller, opts) #completed_redirect = nil, canceled_redirect = nil) @controller_class_name = controller.to_s.camelcase @controller_class_name += 'Controller' unless @controller_class_name =~ /Controller$/ @controller_path = @controller_class_name.sub(/Controller$/,'').underscore @controller_name = @controller_class_name.demodulize.sub(/Controller$/,'').underscore @completed_redirect = opts[:completed] || opts[:when_completed] || opts[:redirect] #format_redirect(completed_redirect) @canceled_redirect = opts[:canceled] || opts[:when_canceled] || opts[:redirect] @include_skip_button = opts[:skip] || opts[:allow_skip] || opts[:allow_skipping] || false @include_cancel_button = opts.key?(:cancel) ? opts[:cancel] : true @guard_entry = opts.key?(:guard) ? opts[:guard] : true @password_fields = opts[:mask_fields] || opts[:mask_passwords] || [:password, :password_confirmation] @persist_model = opts[:persist_model] || :per_page @form_data = opts[:form_data] || :session raise(ArgumentError, ":persist_model option must be one of :once or :per_page", caller) unless [:once, :per_page].include?(@persist_model) raise(ArgumentError, ":form_data option must be one of :sandbox or :session", caller) unless [:sandbox, :session].include?(@form_data) @page_order = [] @pages = {} @buttons = nil @default_buttons = Hash[*[:next, :back, :cancel, :finish, :skip].collect {|default| [default, Button.new(default)] }.flatten] end def guard?; @guard_entry; end def persist_model_per_page?; @persist_model == :per_page; end def form_data_keep_in_session?; @form_data == :session; end def model; @wizard_model_sym; end def model_instance_variable; "@#{@wizard_model_sym.to_s}"; end def model_class_name; @wizard_model_class_name; end def model_const; @wizard_model_const; end def first_page?(name); @page_order.first == name; end def last_page?(name); @page_order.last == name; end def next_page(name) index = @page_order.index(name) index += 1 unless self.last_page?(name) @page_order[index] end def previous_page(name) index = @page_order.index(name) index -= 1 unless self.first_page?(name) @page_order[index] end def button_for_function(name); @default_buttons[name]; end def buttons return @buttons if @buttons # reduce buttons @buttons = Hash[*@default_buttons.collect{|k,v|[v.id, v]}.flatten] end def self.create(controller_name, model_name, opts={}, &block) # controller_name = controller_name.to_s.underscore.sub(/_controller$/, '').to_sym model_name = model_name.to_s.underscore.to_sym config = Wizardly::Wizard::Configuration.new(controller_name, opts) config.inspect_model!(model_name) Wizardly::Wizard::DSL.new(config).instance_eval(&block) if block_given? config end def inspect_model!(model) # first examine the model symbol, transform and see if the constant # exists begin @wizard_model_sym = model.to_sym @wizard_model_class_name = model.to_s.camelize @wizard_model_const = @wizard_model_class_name.constantize rescue Exception=>e raise ModelNotFoundError, "Cannot convert :#{@wizard_model_sym} to model constant for #{@wizard_model_class_name}: " + e.message, caller end begin @page_order = @wizard_model_const.validation_group_order rescue Exception => e raise ValidationGroupError, "Unable to read validation groups from #{@wizard_model_class_name}: " + e.message, caller end raise(ValidationGroupError, "No validation groups defined for model #{@wizard_model_class_name}", caller) unless (@page_order && !@page_order.empty?) begin groups = @wizard_model_const.validation_groups enum_attrs = @wizard_model_const.respond_to?(:enumerated_attributes) ? @wizard_model_const.enumerated_attributes.collect {|k,v| k } : [] model_inst = @wizard_model_const.new last_index = @page_order.size-1 @page_order.each_with_index do |p, index| fields = groups[p].map do |f| column = model_inst.column_for_attribute(f) type = case when enum_attrs.include?(f) then :enum when (@password_fields && @password_fields.include?(f)) then :password else column ? column.type : :string end PageField.new(f, type) end page = Page.new(self, p, fields) # default button settings based on order, can be altered by # set_page(@id).buttons_to [] buttons = [] buttons << @default_buttons[:next] unless index >= last_index buttons << @default_buttons[:finish] if index == last_index buttons << @default_buttons[:back] unless index == 0 buttons << @default_buttons[:skip] if (@include_skip_button && index != last_index) buttons << @default_buttons[:cancel] if (@include_cancel_button) page.buttons = buttons @pages[page.id] = page end rescue Exception => e raise ValidationGroupError, "Failed to configure wizard from #{@wizard_model_class_name} validation groups: " + e.message, caller end end public # internal DSL method handlers def _when_completed_redirect_to(redir); @completed_redirect = redir; end def _when_canceled_redirect_to(redir); @canceled_redirect = redir; end def _change_button(name) raise(WizardConfigurationError, "Button :#{name} in _change_button() call does not exist", caller) unless self.buttons.key?(name) _buttons = self.buttons @buttons = nil # clear the buttons for regeneration after change in next line _buttons[name] end def _create_button(name, opts) id = opts[:id] || button_name_to_symbol(name) raise(WizardConfigurationError, "Button '#{name}' with id :#{id} cannot be created. The ID already exists.", caller) if self.buttons.key?(id) @buttons=nil @default_buttons[id] = UserDefinedButton.new(id, name) end def _set_page(name); @pages[name]; end def _mask_passwords(passwords) case passwords when String passwords = [passwords.to_sym] when Symbol passwords = [passwords] when Array else raise(WizardlyConfigurationError, "mask_passwords method only accepts string, symbol or array of password fields") end @password_fields.push(*passwords).uniq! end def print_config io = StringIO.new class_name = controller_name.to_s.camelize class_name += 'Controller' unless class_name =~ /Controller$/ io.puts "#{class_name} wizard configuration" io.puts io.puts "model: #{model_class_name}" io.puts "instance: @#{model}" io.puts io.puts "pages:" self.page_order.each do |pid| page = pages[pid] # io.puts " #{index+1}. '#{page.title}' page (:#{page.id}) has" io.puts " '#{page.title}' page (:#{page.id}) has" io.puts " --fields: #{page.fields.inject([]){|a, f| a << '"'+f.name.to_s.titleize+'" [:'+f.column_type.to_s+']'}.join(', ')}" io.puts " --buttons: #{page.buttons.inject([]){|a, b| a << b.name.to_s }.join(', ')}" end io.puts io.puts "redirects:" io.puts " when completed: #{completed_redirect ? completed_redirect.inspect : 'redirects to initial referer by default (specify :completed=>url to override)'}" io.puts " when canceled: #{canceled_redirect ? canceled_redirect.inspect : 'redirects to initial referer by default (specify :canceled=>url to override)'}" io.puts io.puts "buttons:" self.buttons.each do |k, b| bs = StringIO.new bs << " #{b.name} (:#{b.id}) " if (b.user_defined?) bs << "-- user defined button and function" else dk = @default_buttons.index(b) bs << "-- used for internal <#{dk}> functionality" end io.puts bs.string end io.puts io.string end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/wizardly/wizard/configuration/methods.rb
lib/wizardly/wizard/configuration/methods.rb
module Wizardly module Wizard class Configuration def print_callback_macros macros = [ %w(on_post _on_post_%s_form), %w(on_get _on_get_%s_form), %w(on_errors _on_invalid_%s_form) ] self.buttons.each do |id, button| macros << ['on_'+ id.to_s, '_on_%s_form_'+ id.to_s ] end mb = StringIO.new macros.each do |macro| mb << <<-MACRO def self.#{macro.first}(*args, &block) self._define_action_callback_macro('#{macro.first}', '#{macro.last}', *args, &block) end MACRO end mb << <<-DEFMAC def self._define_action_callback_macro(macro_first, macro_last, *args, &block) return if args.empty? all_forms = #{page_order.inspect} if args.include?(:all) forms = all_forms else forms = args.map do |fa| unless all_forms.include?(fa) raise(ArgumentError, ":"+fa.to_s+" in callback '" + macro_first + "' is not a form defined for the wizard", caller) end fa end end forms.each do |form| self.send(:define_method, sprintf(macro_last, form.to_s), &block ) hide_action macro_last.to_sym end end DEFMAC [ %w(on_completed _after_wizard_save) ].each do |macro| mb << <<-EVENTS def self.#{macro.first}(&block) self.send(:define_method, :#{macro.last}, &block ) end EVENTS end mb.string end def print_page_action_methods mb = StringIO.new self.pages.each do |id, p| mb << <<-COMMENT # #{id} action method #{self.print_page_action_method(id)} COMMENT end mb << <<-INDEX def index redirect_to :action=>:#{self.page_order.first} end INDEX mb.string end def initial_referer_key @initial_referer_key ||= "#{self.controller_path.sub(/\//, '')}_irk".to_sym end def persist_key; @persist_key ||= "#{self.controller_path.sub(/\//, '')}_dat".to_sym end def progression_key @progression_key ||= "#{self.controller_path.sub(/\//, '')}_prg".to_sym end def print_page_action_method(id) page = @pages[id] finish_button = self.button_for_function(:finish).id next_button = self.button_for_function(:next).id (mb = StringIO.new) << <<-ONE def #{page.name} begin @step = :#{id} @wizard = wizard_config @title = '#{page.title}' @description = '#{page.description}' _build_wizard_model if request.post? && callback_performs_action?(:_on_post_#{id}_form) raise CallbackError, "render or redirect not allowed in :on_post(:#{id}) callback", caller end button_id = check_action_for_button return if performed? if request.get? return if callback_performs_action?(:_on_get_#{id}_form) render_wizard_form return end # @#{self.model}.enable_validation_group :#{id} unless @#{self.model}.valid?(:#{id}) return if callback_performs_action?(:_on_invalid_#{id}_form) render_wizard_form return end @do_not_complete = false ONE if self.last_page?(id) mb << <<-TWO callback_performs_action?(:_on_#{id}_form_#{finish_button}) complete_wizard unless @do_not_complete TWO elsif self.first_page?(id) mb << <<-THREE if button_id == :#{finish_button} callback_performs_action?(:_on_#{id}_form_#{finish_button}) complete_wizard unless @do_not_complete return end return if callback_performs_action?(:_on_#{id}_form_#{next_button}) redirect_to :action=>:#{self.next_page(id)} THREE else mb << <<-FOUR if button_id == :#{finish_button} callback_performs_action?(:_on_#{id}_form_#{finish_button}) complete_wizard unless @do_not_complete return end return if callback_performs_action?(:_on_#{id}_form_#{next_button}) redirect_to :action=>:#{self.next_page(id)} FOUR end mb << <<-ENSURE ensure _preserve_wizard_model end end ENSURE mb.string end def print_callbacks finish = self.button_for_function(:finish).id skip = self.button_for_function(:skip).id back = self.button_for_function(:back).id cancel = self.button_for_function(:cancel).id <<-CALLBACKS protected def _on_wizard_#{finish} return if @wizard_completed_flag @#{self.model}.save_without_validation! if @#{self.model}.changed? @wizard_completed_flag = true reset_wizard_form_data _wizard_final_redirect_to(:completed) end def _on_wizard_#{skip} self.progression = self.progression - [@step] redirect_to(:action=>wizard_config.next_page(@step)) unless self.performed? end def _on_wizard_#{back} redirect_to(:action=>(previous_in_progression_from(@step) || :#{self.page_order.first})) unless self.performed? end def _on_wizard_#{cancel} _wizard_final_redirect_to(:canceled) end def _wizard_final_redirect_to(type) init = (type == :canceled && wizard_config.form_data_keep_in_session?) ? self.initial_referer : reset_wizard_session_vars unless self.performed? redir = (type == :canceled ? wizard_config.canceled_redirect : wizard_config.completed_redirect) || init return redirect_to(redir) if redir raise Wizardly::RedirectNotDefinedError, "No redirect was defined for completion or canceling the wizard. Use :completed and :canceled options to define redirects.", caller end end hide_action :_on_wizard_#{finish}, :_on_wizard_#{skip}, :_on_wizard_#{back}, :_on_wizard_#{cancel}, :_wizard_final_redirect_to CALLBACKS end def print_helpers next_id = self.button_for_function(:next).id finish_id = self.button_for_function(:finish).id first_page = self.page_order.first finish_button = self.button_for_function(:finish).id guard_line = self.guard? ? '' : 'return check_progression #guard entry disabled' mb = StringIO.new mb << <<-PROGRESSION protected def do_not_complete; @do_not_complete = true; end def previous_in_progression_from(step) po = #{self.page_order.inspect} p = self.progression p -= po[po.index(step)..-1] self.progression = p p.last end def check_progression p = self.progression a = params[:action].to_sym return if p.last == a po = #{self.page_order.inspect} return unless (ai = po.index(a)) p -= po[ai..-1] p << a self.progression = p end PROGRESSION if self.form_data_keep_in_session? mb << <<-SESSION # for :form_data=>:session def guard_entry if (r = request.env['HTTP_REFERER']) begin h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get}) rescue else return check_progression if (h[:controller]||'') == '#{self.controller_path}' self.initial_referer = h unless self.initial_referer end end # coming from outside the controller or no route for GET #{guard_line} if (params[:action] == '#{first_page}' || params[:action] == 'index') return check_progression elsif self.wizard_form_data p = self.progression return check_progression if p.include?(params[:action].to_sym) return redirect_to(:action=>(p.last||:#{first_page})) end redirect_to :action=>:#{first_page} end hide_action :guard_entry SESSION else mb << <<-SANDBOX # for :form_data=>:sandbox def guard_entry if (r = request.env['HTTP_REFERER']) begin h = ::ActionController::Routing::Routes.recognize_path(URI.parse(r).path, {:method=>:get}) rescue else return check_progression if (h[:controller]||'') == '#{self.controller_path}' self.initial_referer = h end else self.initial_referer = nil end # coming from outside the controller reset_wizard_form_data #{guard_line} return redirect_to(:action=>:#{first_page}) unless (params[:action] || '') == '#{first_page}' check_progression end hide_action :guard_entry SANDBOX end mb << <<-HELPERS def render_and_return return if callback_performs_action?('_on_get_'+@step.to_s+'_form') render_wizard_form render unless self.performed? end def complete_wizard(redirect = nil) unless @wizard_completed_flag @#{self.model}.save_without_validation! callback_performs_action?(:_after_wizard_save) end redirect_to redirect if (redirect && !self.performed?) return if @wizard_completed_flag _on_wizard_#{finish_button} redirect_to(#{Utils.formatted_redirect(self.completed_redirect)}) unless self.performed? end def _build_wizard_model if self.wizard_config.persist_model_per_page? h = self.wizard_form_data if (h && model_id = h['id']) _model = #{self.model_class_name}.find(model_id) _model.attributes = params[:#{self.model}]||{} @#{self.model} = _model return end @#{self.model} = #{self.model_class_name}.new(params[:#{self.model}]) else # persist data in session or flash h = (self.wizard_form_data||{}).merge(params[:#{self.model}] || {}) @#{self.model} = #{self.model_class_name}.new(h) end end def _preserve_wizard_model return unless (@#{self.model} && !@wizard_completed_flag) if self.wizard_config.persist_model_per_page? @#{self.model}.save_without_validation! if request.get? @#{self.model}.errors.clear else @#{self.model}.reject_non_validation_group_errors end self.wizard_form_data = {'id'=>@#{self.model}.id} else self.wizard_form_data = @#{self.model}.attributes end end hide_action :_build_wizard_model, :_preserve_wizard_model def initial_referer session[:#{self.initial_referer_key}] end def initial_referer=(val) session[:#{self.initial_referer_key}] = val end def progression=(array) session[:#{self.progression_key}] = array end def progression session[:#{self.progression_key}]||[] end hide_action :progression, :progression=, :initial_referer, :initial_referer= def wizard_form_data=(hash) if wizard_config.form_data_keep_in_session? session[:#{self.persist_key}] = hash else if hash flash[:#{self.persist_key}] = hash else flash.discard(:#{self.persist_key}) end end end def reset_wizard_form_data; self.wizard_form_data = nil; end def wizard_form_data wizard_config.form_data_keep_in_session? ? session[:#{self.persist_key}] : flash[:#{self.persist_key}] end hide_action :wizard_form_data, :wizard_form_data=, :reset_wizard_form_data def render_wizard_form end hide_action :render_wizard_form def performed?; super; end hide_action :performed? def underscore_button_name(value) value.to_s.strip.squeeze(' ').gsub(/ /, '_').downcase end hide_action :underscore_button_name def reset_wizard_session_vars self.progression = nil init = self.initial_referer self.initial_referer = nil init end hide_action :reset_wizard_session_vars def check_action_for_button button_id = nil case when params[:commit] button_name = params[:commit] button_id = underscore_button_name(button_name).to_sym when ((b_ar = self.wizard_config.buttons.find{|k,b| params[k]}) && params[b_ar.first] == b_ar.last.name) button_name = b_ar.last.name button_id = b_ar.first end if button_id unless [:#{next_id}, :#{finish_id}].include?(button_id) action_method_name = "_on_" + params[:action].to_s + "_form_" + button_id.to_s callback_performs_action?(action_method_name) unless ((btn_obj = self.wizard_config.buttons[button_id]) == nil || btn_obj.user_defined?) method_name = "_on_wizard_" + button_id.to_s if (self.method(method_name)) self.__send__(method_name) else raise MissingCallbackError, "Callback method either '" + action_method_name + "' or '" + method_name + "' not defined", caller end end end end button_id end hide_action :check_action_for_button @wizard_callbacks ||= [] def self.wizard_callbacks; @wizard_callbacks; end def callback_performs_action?(methId) cache = self.class.wizard_callbacks return false if cache.include?(methId) if self.respond_to?(methId, true) self.send(methId) else cache << methId return false end self.performed? end hide_action :callback_performs_action? HELPERS mb.string end end end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_app/wizardly_app_generator.rb
lib/generators/wizardly_app/wizardly_app_generator.rb
#require 'wizardly' class WizardlyAppGenerator < Rails::Generator::Base def initialize(runtime_args, runtime_options = {}) super end def manifest record do |m| m.directory "lib/tasks" m.file "wizardly.rake", "lib/tasks/wizardly.rake" end end def controller_class_name "#{controller_name.camelize}Controller" end def model_class_name "#{model_name.camelize}" end def action_methods @wizard_config.print_page_action_methods end def callback_methods @wizard_config.print_callbacks end def helper_methods @wizard_config.print_helpers end protected # Override with your own usage banner. def banner "Usage: #{$0} wizardly_app" end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_controller/wizardly_controller_generator.rb
lib/generators/wizardly_controller/wizardly_controller_generator.rb
require 'wizardly' class WizardlyControllerGenerator < Rails::Generator::Base attr_reader :controller_name, :model_name, :completed_redirect, :canceled_redirect def initialize(runtime_args, runtime_options = {}) super @controller_name = @args[0].sub(/^:/,'') @model_name = @args[1].sub(/^:/, '').underscore @completed_redirect = @args[2] @canceled_redirect = @args[3] opts = {} opts[:completed] = @completed_redirect if @completed_redirect opts[:canceled] = @canceled_redirect if @canceled_redirect @wizard_config = Wizardly::Wizard::Configuration.new(@controller_name, opts) @wizard_config.inspect_model!(@model_name.to_sym) end def manifest record do |m| m.directory "app/controllers" m.template "controller.rb.erb", "app/controllers/#{controller_name}_controller.rb" m.template "helper.rb.erb", "app/helpers/#{controller_name}_helper.rb" end end def controller_class_name "#{controller_name.camelize}Controller" end def model_class_name "#{model_name.camelize}" end def action_methods @wizard_config.print_page_action_methods end def callback_methods @wizard_config.print_callbacks end def helper_methods @wizard_config.print_helpers end def callback_macro_methods @wizard_config.print_callback_macros end protected # Override with your own usage banner. def banner "Usage: #{$0} wizardly_controller controller_name model_name [completed_redirect canceled_redirect]" end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/lib/generators/wizardly_scaffold/wizardly_scaffold_generator.rb
lib/generators/wizardly_scaffold/wizardly_scaffold_generator.rb
require 'wizardly' class WizardlyScaffoldGenerator < Rails::Generator::Base attr_reader :wizard_config, :pages, :submit_tag attr_reader :controller_name, :controller_class_path, :controller_file_path, :controller_class_nesting, :controller_class_nesting_depth, :controller_class_name, :controller_underscore_name attr_reader :model_name, :view_file_ext alias_method :controller_file_name, :controller_underscore_name def add_options!(opt) opt.on('--haml', 'Generate scaffold for haml wizard') { |v| options[:output] = :haml } opt.on('--ajax', 'Generate scaffold for ajax wizard') { |v| options[:output] = :ajax } opt.on('--underscore', 'Append an underscore to front of each file') { |v| options[:underscore] = true } opt.on('--image_submit', 'Use image submit tags in forms') {|v| options[:image_submit] = true } end def initialize(runtime_args, runtime_options = {}) super name = @args[0].sub(/^:/, '').underscore.sub(/_controller$/, '').camelize + 'Controller' base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(name) @controller_class_name_without_nesting = base_name.camelize @controller_underscore_name = base_name.underscore @controller_name = @controller_underscore_name.sub(/_controller$/, '') if @controller_class_nesting.empty? @controller_class_name = @controller_class_name_without_nesting else @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" end begin @controller_class = @controller_class_name.constantize rescue Exception => e raise Wizardly::WizardlyScaffoldError, "No controller #{@controller_class_name} found: " + e.message, caller end begin @wizard_config = @controller_class.wizard_config rescue Exception => e raise Wizardly::WizardlyScaffoldError, "#{@controller_class_name} must contain a valid 'act_wizardly_for' or 'wizard_for_model' macro: " + e.message, caller end @pages = @wizard_config.pages @model_name = @wizard_config.model @submit_tag = options[:image_submit] ? "wizardly_image_submit" : "wizardly_submit" #based on options, default is --html, others --ajax, --haml @view_file_ext = ["html.erb", "html.erb"] @view_file_ext = ["html.haml.erb", "html.haml"] if options[:output] == :haml #ajax end def manifest record do |m| # Helper, views, test and stylesheets directories. m.directory(File.join('app/helpers', controller_class_path)) m.directory(File.join('app/views', controller_class_path, controller_name)) m.directory(File.join('app/views/layouts', controller_class_path)) m.directory('public/images/wizardly') if options[:image_submit] #m.directory(File.join('test/functional', controller_class_path)) #m.directory(File.join('public/stylesheets', class_path)) underscore = options[:underscore] ? '_' : '' pages.each do |id, page| m.template( "form.#{view_file_ext.first}", File.join('app/views', controller_class_path, controller_name, "#{underscore}#{id}.#{view_file_ext.last}"), :assigns=>{:id=>id, :page=>page} ) end if options[:image_submit] %w(next skip back cancel finish).each do |fn| m.file("images/#{fn}.png", "public/images/wizardly/#{fn}.png") end end m.template("helper.rb.erb", File.join('app/helpers', controller_class_path, "#{controller_name}_helper.rb")) # Layout and stylesheet. m.template("layout.#{view_file_ext.first}", File.join('app/views/layouts', controller_class_path, "#{controller_name}.#{view_file_ext.last}")) m.template('style.css', 'public/stylesheets/scaffold.css') #m.dependency 'model', [name] + @args, :collision => :skip end end protected def banner "Usage: #{$0} wizardly_scaffold controller_name --ajax --haml" end def extract_modules(name) modules = name.include?('/') ? name.split('/') : name.split('::') name = modules.pop path = modules.map { |m| m.underscore } file_path = (path + [name.underscore]).join('/') nesting = modules.map { |m| m.camelize }.join('::') [name, path, file_path, nesting, modules.size] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/environment.rb
config/environment.rb
# Be sure to restart your server when you modify this file # Specifies gem version of Rails to use when vendor/rails is not present RAILS_GEM_VERSION = '>=2.2.1' unless defined? RAILS_GEM_VERSION # Bootstrap the Rails environment, frameworks, and default configuration require File.join(File.dirname(__FILE__), 'boot') Rails::Initializer.run do |config| # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Add additional load paths for your own custom dirs # config.load_paths += %W( #{RAILS_ROOT}/extras ) # Specify gems that this application depends on and have them installed with rake gems:install # config.gem "bj" # config.gem "hpricot", :version => '0.6', :source => "http://code.whytheluckystiff.net" # config.gem "sqlite3-ruby", :lib => "sqlite3" # config.gem "aws-s3", :lib => "aws/s3" #config.gem "#{Rails::GemDependency.new("enumerated_attribute").installed? ? "" : "jeffp-"}enumerated_attribute" config.gem "thoughtbot-paperclip", :lib=>"paperclip", :source=>"http://gems.github.com" # Only load the plugins named here, in the order given (default is alphabetical). # :all can be used as a placeholder for all plugins not explicitly named # config.plugins = [ :exception_notification, :ssl_requirement, :all ] # Skip frameworks you're not going to use. To use Rails without a database, # you must remove the Active Record framework. # config.frameworks -= [ :active_record, :active_resource, :action_mailer ] # Activate observers that should always be running # config.active_record.observers = :cacher, :garbage_collector, :forum_observer config.action_controller.session_store = :active_record_store # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. config.time_zone = 'UTC' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')] # config.i18n.default_locale = :de end require 'wizardly'
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/routes.rb
config/routes.rb
ActionController::Routing::Routes.draw do |map| # The priority is based upon order of creation: first created -> highest priority. map.root :controller=>'main' # Sample of regular route: # map.connect 'products/:id', :controller => 'catalog', :action => 'view' # Keep in mind you can assign values other than :controller and :action # Sample of named route: # map.purchase 'products/:id/purchase', :controller => 'catalog', :action => 'purchase' # This route can be invoked with purchase_url(:id => product.id) # Sample resource route (maps HTTP verbs to controller actions automatically): # map.resources :products # Sample resource route with options: # map.resources :products, :member => { :short => :get, :toggle => :post }, :collection => { :sold => :get } # Sample resource route with sub-resources: # map.resources :products, :has_many => [ :comments, :sales ], :has_one => :seller # Sample resource route with more complex sub-resources # map.resources :products do |products| # products.resources :comments # products.resources :sales, :collection => { :recent => :get } # end # Sample resource route within a namespace: # map.namespace :admin do |admin| # # Directs /admin/products/* to Admin::ProductsController (app/controllers/admin/products_controller.rb) # admin.resources :products # end # You can have the root of your site routed with map.root -- just remember to delete public/index.html. # map.root :controller => "welcome" # See how all your routes lay out with "rake routes" # Install the default routes as the lowest priority. # Note: These default routes make all actions in every controller accessible via GET requests. You should # consider removing the them or commenting them out if you're using named routes and resources. map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/boot.rb
config/boot.rb
# Don't change this file! # Configure your app in config/environment.rb and config/environments/*.rb RAILS_ROOT = "#{File.dirname(__FILE__)}/.." unless defined?(RAILS_ROOT) module Rails class << self def boot! unless booted? preinitialize pick_boot.run end end def booted? defined? Rails::Initializer end def pick_boot (vendor_rails? ? VendorBoot : GemBoot).new end def vendor_rails? File.exist?("#{RAILS_ROOT}/vendor/rails") end def preinitialize load(preinitializer_path) if File.exist?(preinitializer_path) end def preinitializer_path "#{RAILS_ROOT}/config/preinitializer.rb" end end class Boot def run load_initializer Rails::Initializer.run(:set_load_path) end end class VendorBoot < Boot def load_initializer require "#{RAILS_ROOT}/vendor/rails/railties/lib/initializer" Rails::Initializer.run(:install_gem_spec_stubs) Rails::GemDependency.add_frozen_gem_path end end class GemBoot < Boot def load_initializer self.class.load_rubygems load_rails_gem require 'initializer' end def load_rails_gem if version = self.class.gem_version gem 'rails', version else gem 'rails' end rescue Gem::LoadError => load_error $stderr.puts %(Missing the Rails #{version} gem. Please `gem install -v=#{version} rails`, update your RAILS_GEM_VERSION setting in config/environment.rb for the Rails version you do have installed, or comment out RAILS_GEM_VERSION to use the latest version installed.) exit 1 end class << self def rubygems_version Gem::RubyGemsVersion rescue nil end def gem_version if defined? RAILS_GEM_VERSION RAILS_GEM_VERSION elsif ENV.include?('RAILS_GEM_VERSION') ENV['RAILS_GEM_VERSION'] else parse_gem_version(read_environment_rb) end end def load_rubygems require 'rubygems' min_version = '1.3.1' unless rubygems_version >= min_version $stderr.puts %Q(Rails requires RubyGems >= #{min_version} (you have #{rubygems_version}). Please `gem update --system` and try again.) exit 1 end rescue LoadError $stderr.puts %Q(Rails requires RubyGems >= #{min_version}. Please install RubyGems and try again: http://rubygems.rubyforge.org) exit 1 end def parse_gem_version(text) $1 if text =~ /^[^#]*RAILS_GEM_VERSION\s*=\s*["']([!~<>=]*\s*[\d.]+)["']/ end private def read_environment_rb File.read("#{RAILS_ROOT}/config/environment.rb") end end end end # All that for this: Rails.boot!
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. # Your secret key for verifying cookie session data integrity. # If you change this key, all old sessions will become invalid! # Make sure the secret is at least 30 characters and all random, # no regular words or you'll be exposed to dictionary attacks. ActionController::Base.session = { :key => '_wizard_session', :secret => 'bbd1b39720a747639fea9e3b40b5db4d67cabdedab097746587fdd9d390c1ce2108d812fd23054eb9ac0c6d4bbb07357a532cd8cf0e847cac5cc319ab1364175' } # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information # (create the session table with "rake db:sessions:create") # ActionController::Base.session_store = :active_record_store
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/initializers/new_rails_defaults.rb
config/initializers/new_rails_defaults.rb
# Be sure to restart your server when you modify this file. # These settings change the behavior of Rails 2 apps and will be defaults # for Rails 3. You can remove this initializer when Rails 3 is released. if defined?(ActiveRecord) # Include Active Record class name as root for JSON serialized output. ActiveRecord::Base.include_root_in_json = true # Store the full class name (including module namespace) in STI type column. ActiveRecord::Base.store_full_sti_class = true end # Use ISO 8601 format for JSON serialized times and dates. ActiveSupport.use_standard_json_time_format = true # Don't escape HTML entities in JSON, leave that for the #json_escape helper. # if you're including raw json in an HTML page. ActiveSupport.escape_html_entities_in_json = false
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/initializers/inflections.rb
config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format # (all these examples are active by default): # ActiveSupport::Inflector.inflections do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/initializers/backtrace_silencers.rb
config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying do debug a problem that might steem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/initializers/mime_types.rb
config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf # Mime::Type.register_alias "text/html", :iphone
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/environments/test.rb
config/environments/test.rb
# Settings specified here will take precedence over those in config/environment.rb # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_controller.perform_caching = false config.action_view.cache_template_loading = true # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Use SQL instead of Active Record's schema dumper when creating the test database. # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql config.gem "webrat", :version=>">=0.4.3"
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/environments/development.rb
config/environments/development.rb
# Settings specified here will take precedence over those in config/environment.rb # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the webserver when you make code changes. config.cache_classes = false # Log error messages when you accidentally call methods on nil. config.whiny_nils = true # Show full error reports and disable caching config.action_controller.consider_all_requests_local = true config.action_view.debug_rjs = true config.action_controller.perform_caching = false # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/config/environments/production.rb
config/environments/production.rb
# Settings specified here will take precedence over those in config/environment.rb # The production environment is meant for finished, "live" apps. # Code is not reloaded between requests config.cache_classes = true # Full error reports are disabled and caching is turned on config.action_controller.consider_all_requests_local = false config.action_controller.perform_caching = true config.action_view.cache_template_loading = true # See everything in the log (default is :info) # config.log_level = :debug # Use a different logger for distributed setups # config.logger = SyslogLogger.new # Use a different cache store in production # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and javascripts from an asset server # config.action_controller.asset_host = "http://assets.example.com" # Disable delivery errors, bad email addresses will be ignored # config.action_mailer.raise_delivery_errors = false # Enable threaded mode # config.threadsafe!
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_app/wizardly_app_generator.rb
rails_generators/wizardly_app/wizardly_app_generator.rb
#require 'wizardly' class WizardlyAppGenerator < Rails::Generator::Base def initialize(runtime_args, runtime_options = {}) super end def manifest record do |m| m.directory "lib/tasks" m.file "wizardly.rake", "lib/tasks/wizardly.rake" end end def controller_class_name "#{controller_name.camelize}Controller" end def model_class_name "#{model_name.camelize}" end def action_methods @wizard_config.print_page_action_methods end def callback_methods @wizard_config.print_callbacks end def helper_methods @wizard_config.print_helpers end protected # Override with your own usage banner. def banner "Usage: #{$0} wizardly_app" end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_controller/wizardly_controller_generator.rb
rails_generators/wizardly_controller/wizardly_controller_generator.rb
require 'wizardly' class WizardlyControllerGenerator < Rails::Generator::Base attr_reader :controller_name, :model_name, :completed_redirect, :canceled_redirect def initialize(runtime_args, runtime_options = {}) super @controller_name = @args[0].sub(/^:/,'') @model_name = @args[1].sub(/^:/, '').underscore @completed_redirect = @args[2] @canceled_redirect = @args[3] opts = {} opts[:completed] = @completed_redirect if @completed_redirect opts[:canceled] = @canceled_redirect if @canceled_redirect @wizard_config = Wizardly::Wizard::Configuration.new(@controller_name, opts) @wizard_config.inspect_model!(@model_name.to_sym) end def manifest record do |m| m.directory "app/controllers" m.template "controller.rb.erb", "app/controllers/#{controller_name}_controller.rb" m.template "helper.rb.erb", "app/helpers/#{controller_name}_helper.rb" end end def controller_class_name "#{controller_name.camelize}Controller" end def model_class_name "#{model_name.camelize}" end def action_methods @wizard_config.print_page_action_methods end def callback_methods @wizard_config.print_callbacks end def helper_methods @wizard_config.print_helpers end def callback_macro_methods @wizard_config.print_callback_macros end protected # Override with your own usage banner. def banner "Usage: #{$0} wizardly_controller controller_name model_name [completed_redirect canceled_redirect]" end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
jeffp/wizardly
https://github.com/jeffp/wizardly/blob/130f350f3916a5079bd3db1a55c292eeb4115122/rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb
rails_generators/wizardly_scaffold/wizardly_scaffold_generator.rb
require 'wizardly' class WizardlyScaffoldGenerator < Rails::Generator::Base attr_reader :wizard_config, :pages, :submit_tag attr_reader :controller_name, :controller_class_path, :controller_file_path, :controller_class_nesting, :controller_class_nesting_depth, :controller_class_name, :controller_underscore_name attr_reader :model_name, :view_file_ext alias_method :controller_file_name, :controller_underscore_name def add_options!(opt) opt.on('--haml', 'Generate scaffold for haml wizard') { |v| options[:output] = :haml } opt.on('--ajax', 'Generate scaffold for ajax wizard') { |v| options[:output] = :ajax } opt.on('--underscore', 'Append an underscore to front of each file') { |v| options[:underscore] = true } opt.on('--image_submit', 'Use image submit tags in forms') {|v| options[:image_submit] = true } end def initialize(runtime_args, runtime_options = {}) super name = @args[0].sub(/^:/, '').underscore.sub(/_controller$/, '').camelize + 'Controller' base_name, @controller_class_path, @controller_file_path, @controller_class_nesting, @controller_class_nesting_depth = extract_modules(name) @controller_class_name_without_nesting = base_name.camelize @controller_underscore_name = base_name.underscore @controller_name = @controller_underscore_name.sub(/_controller$/, '') if @controller_class_nesting.empty? @controller_class_name = @controller_class_name_without_nesting else @controller_class_name = "#{@controller_class_nesting}::#{@controller_class_name_without_nesting}" end begin @controller_class = @controller_class_name.constantize rescue Exception => e raise Wizardly::WizardlyScaffoldError, "No controller #{@controller_class_name} found: " + e.message, caller end begin @wizard_config = @controller_class.wizard_config rescue Exception => e raise Wizardly::WizardlyScaffoldError, "#{@controller_class_name} must contain a valid 'act_wizardly_for' or 'wizard_for_model' macro: " + e.message, caller end @pages = @wizard_config.pages @model_name = @wizard_config.model @submit_tag = options[:image_submit] ? "wizardly_image_submit" : "wizardly_submit" #based on options, default is --html, others --ajax, --haml @view_file_ext = ["html.erb", "html.erb"] @view_file_ext = ["html.haml.erb", "html.haml"] if options[:output] == :haml #ajax end def manifest record do |m| # Helper, views, test and stylesheets directories. m.directory(File.join('app/helpers', controller_class_path)) m.directory(File.join('app/views', controller_class_path, controller_name)) m.directory(File.join('app/views/layouts', controller_class_path)) m.directory('public/images/wizardly') if options[:image_submit] #m.directory(File.join('test/functional', controller_class_path)) #m.directory(File.join('public/stylesheets', class_path)) underscore = options[:underscore] ? '_' : '' pages.each do |id, page| m.template( "form.#{view_file_ext.first}", File.join('app/views', controller_class_path, controller_name, "#{underscore}#{id}.#{view_file_ext.last}"), :assigns=>{:id=>id, :page=>page} ) end if options[:image_submit] %w(next skip back cancel finish).each do |fn| m.file("images/#{fn}.png", "public/images/wizardly/#{fn}.png") end end m.template("helper.rb.erb", File.join('app/helpers', controller_class_path, "#{controller_name}_helper.rb")) # Layout and stylesheet. m.template("layout.#{view_file_ext.first}", File.join('app/views/layouts', controller_class_path, "#{controller_name}.#{view_file_ext.last}")) m.template('style.css', 'public/stylesheets/scaffold.css') #m.dependency 'model', [name] + @args, :collision => :skip end end protected def banner "Usage: #{$0} wizardly_scaffold controller_name --ajax --haml" end def extract_modules(name) modules = name.include?('/') ? name.split('/') : name.split('::') name = modules.pop path = modules.map { |m| m.underscore } file_path = (path + [name.underscore]).join('/') nesting = modules.map { |m| m.camelize }.join('::') [name, path, file_path, nesting, modules.size] end end
ruby
MIT
130f350f3916a5079bd3db1a55c292eeb4115122
2026-01-04T17:48:58.245731Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/spec/spec_helper.rb
spec/spec_helper.rb
# encoding: UTF-8 require 'rubygems' require 'bundler' Bundler.setup(:default, :test) Bundler.require(:default, :test) require 'pry' ROOT = File.dirname(File.dirname(__FILE__)) if ENV['TRAVIS'] require 'coveralls' Coveralls.wear! end $TESTING=true $:.unshift File.join(File.dirname(__FILE__), '..', 'lib')
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/jobs/application_job.rb
example/example/app/jobs/application_job.rb
class ApplicationJob < ActiveJob::Base end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/helpers/books_helper.rb
example/example/app/helpers/books_helper.rb
module BooksHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/helpers/articles_helper.rb
example/example/app/helpers/articles_helper.rb
module ArticlesHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/helpers/application_helper.rb
example/example/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/controllers/articles_controller.rb
example/example/app/controllers/articles_controller.rb
class ArticlesController < ApplicationController before_action :set_article, only: [:show, :edit, :update, :destroy] # GET /articles # GET /articles.json def index @articles = Article.all end # GET /articles/1 # GET /articles/1.json def show end # GET /articles/new def new @article = Article.new end # GET /articles/1/edit def edit end # POST /articles # POST /articles.json def create @article = Article.new(article_params) respond_to do |format| if @article.save format.html { redirect_to @article, notice: 'Article was successfully created.' } format.json { render :show, status: :created, location: @article } else format.html { render :new } format.json { render json: @article.errors, status: :unprocessable_entity } end end end # PATCH/PUT /articles/1 # PATCH/PUT /articles/1.json def update respond_to do |format| if @article.update(article_params) format.html { redirect_to @article, notice: 'Article was successfully updated.' } format.json { render :show, status: :ok, location: @article } else format.html { render :edit } format.json { render json: @article.errors, status: :unprocessable_entity } end end end # DELETE /articles/1 # DELETE /articles/1.json def destroy @article.destroy respond_to do |format| format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_article @article = Article.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def article_params params.require(:article).permit(:title) end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/controllers/books_controller.rb
example/example/app/controllers/books_controller.rb
class BooksController < ApplicationController before_action :set_book, only: [:show, :edit, :update, :destroy] # GET /books # GET /books.json def index @books = Book.all end # GET /books/1 # GET /books/1.json def show end # GET /books/new def new @book = Book.new end # GET /books/1/edit def edit end # POST /books # POST /books.json def create @book = Book.new(book_params) respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render :show, status: :created, location: @book } else format.html { render :new } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # PATCH/PUT /books/1 # PATCH/PUT /books/1.json def update respond_to do |format| if @book.update(book_params) format.html { redirect_to @book, notice: 'Book was successfully updated.' } format.json { render :show, status: :ok, location: @book } else format.html { render :edit } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # DELETE /books/1 # DELETE /books/1.json def destroy @book.destroy respond_to do |format| format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_book @book = Book.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def book_params params.require(:book).permit(:title) end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/controllers/application_controller.rb
example/example/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base protect_from_forgery with: :exception end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/models/book.rb
example/example/app/models/book.rb
class Book < ApplicationRecord end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/models/article.rb
example/example/app/models/article.rb
class Article < ApplicationRecord end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/models/application_record.rb
example/example/app/models/application_record.rb
class ApplicationRecord < ActiveRecord::Base self.abstract_class = true end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/mailers/application_mailer.rb
example/example/app/mailers/application_mailer.rb
class ApplicationMailer < ActionMailer::Base default from: 'from@example.com' layout 'mailer' end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/channels/application_cable/channel.rb
example/example/app/channels/application_cable/channel.rb
module ApplicationCable class Channel < ActionCable::Channel::Base end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/app/channels/application_cable/connection.rb
example/example/app/channels/application_cable/connection.rb
module ApplicationCable class Connection < ActionCable::Connection::Base end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/db/seeds.rb
example/example/db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rails db:seed command (or created alongside the database with db:setup). # # Examples: # # movies = Movie.create([{ name: 'Star Wars' }, { name: 'Lord of the Rings' }]) # Character.create(name: 'Luke', movie: movies.first)
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/db/schema.rb
example/example/db/schema.rb
# This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20160708030050) do create_table "articles", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "title" t.datetime "created_at", null: false t.datetime "updated_at", null: false end create_table "books", force: :cascade, options: "ENGINE=InnoDB DEFAULT CHARSET=utf8" do |t| t.string "title" t.datetime "created_at", null: false t.datetime "updated_at", null: false end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/db/migrate/20160708030008_create_books.rb
example/example/db/migrate/20160708030008_create_books.rb
class CreateBooks < ActiveRecord::Migration[5.0] def change create_table :books do |t| t.string :title t.timestamps end end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/db/migrate/20160708030050_create_articles.rb
example/example/db/migrate/20160708030050_create_articles.rb
class CreateArticles < ActiveRecord::Migration[5.0] def change create_table :articles do |t| t.string :title t.timestamps end end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/test/test_helper.rb
example/example/test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. fixtures :all # Add more helper methods to be used by all tests here... end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/test/controllers/books_controller_test.rb
example/example/test/controllers/books_controller_test.rb
require 'test_helper' class BooksControllerTest < ActionDispatch::IntegrationTest setup do @book = books(:one) end test "should get index" do get books_url assert_response :success end test "should get new" do get new_book_url assert_response :success end test "should create book" do assert_difference('Book.count') do post books_url, params: { book: { title: @book.title } } end assert_redirected_to book_url(Book.last) end test "should show book" do get book_url(@book) assert_response :success end test "should get edit" do get edit_book_url(@book) assert_response :success end test "should update book" do patch book_url(@book), params: { book: { title: @book.title } } assert_redirected_to book_url(@book) end test "should destroy book" do assert_difference('Book.count', -1) do delete book_url(@book) end assert_redirected_to books_url end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/test/controllers/articles_controller_test.rb
example/example/test/controllers/articles_controller_test.rb
require 'test_helper' class ArticlesControllerTest < ActionDispatch::IntegrationTest setup do @article = articles(:one) end test "should get index" do get articles_url assert_response :success end test "should get new" do get new_article_url assert_response :success end test "should create article" do assert_difference('Article.count') do post articles_url, params: { article: { title: @article.title } } end assert_redirected_to article_url(Article.last) end test "should show article" do get article_url(@article) assert_response :success end test "should get edit" do get edit_article_url(@article) assert_response :success end test "should update article" do patch article_url(@article), params: { article: { title: @article.title } } assert_redirected_to article_url(@article) end test "should destroy article" do assert_difference('Article.count', -1) do delete article_url(@article) end assert_redirected_to articles_url end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/test/models/article_test.rb
example/example/test/models/article_test.rb
require 'test_helper' class ArticleTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/test/models/book_test.rb
example/example/test/models/book_test.rb
require 'test_helper' class BookTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/application.rb
example/example/config/application.rb
require_relative 'boot' require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Example class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. config.middleware.insert_before ActionDispatch::Executor, "ActiveRecord::ConnectionAdapters::RefreshConnectionManagement" end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/environment.rb
example/example/config/environment.rb
# Load the Rails application. require_relative 'application' # Initialize the Rails application. Rails.application.initialize!
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/puma.rb
example/example/config/puma.rb
# Puma can serve each request in a thread from an internal thread pool. # The `threads` method setting takes two numbers a minimum and maximum. # Any libraries that use thread pools should be configured to match # the maximum value specified for Puma. Default is set to 5 threads for minimum # and maximum, this matches the default thread size of Active Record. # threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i threads threads_count, threads_count # Specifies the `port` that Puma will listen on to receive requests, default is 3000. # port ENV.fetch("PORT") { 3000 } # Specifies the `environment` that Puma will run in. # environment ENV.fetch("RAILS_ENV") { "development" } # Specifies the number of `workers` to boot in clustered mode. # Workers are forked webserver processes. If using threads and workers together # the concurrency of the application would be max `threads` * `workers`. # Workers do not work on JRuby or Windows (both of which do not support # processes). # # workers ENV.fetch("WEB_CONCURRENCY") { 2 } # Use the `preload_app!` method when specifying a `workers` number. # This directive tells Puma to first boot the application and load code # before forking the application. This takes advantage of Copy On Write # process behavior so workers use less memory. If you use this option # you need to make sure to reconnect any threads in the `on_worker_boot` # block. # # preload_app! # The code in the `on_worker_boot` will be called if you are using # clustered mode by specifying a number of `workers`. After each worker # process is booted this block will be run, if you are using `preload_app!` # option you will want to use this block to reconnect to any threads # or connections that may have been created at application boot, Ruby # cannot share connections between processes. # # on_worker_boot do # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) # end # Allow puma to be restarted by `rails restart` command. plugin :tmp_restart
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/routes.rb
example/example/config/routes.rb
Rails.application.routes.draw do resources :articles resources :books # For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/spring.rb
example/example/config/spring.rb
%w( .ruby-version .rbenv-vars tmp/restart.txt tmp/caching-dev.txt ).each { |path| Spring.watch(path) }
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/unicorn.rb
example/example/config/unicorn.rb
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3) timeout 15 preload_app true listen 3000 # "/tmp/unicorn.sock" pid "/tmp/unicorn.pid" before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end # stderr_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT']) # stdout_path File.expand_path('log/unicorn.log', ENV['RAILS_ROOT'])
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/boot.rb
example/example/config/boot.rb
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) require 'bundler/setup' # Set up gems listed in the Gemfile.
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/filter_parameter_logging.rb
example/example/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/application_controller_renderer.rb
example/example/config/initializers/application_controller_renderer.rb
# Be sure to restart your server when you modify this file. # ApplicationController.renderer.defaults.merge!( # http_host: 'example.org', # https: false # )
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/session_store.rb
example/example/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_example_session'
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/new_framework_defaults.rb
example/example/config/initializers/new_framework_defaults.rb
# Be sure to restart your server when you modify this file. # # This file contains migration options to ease your Rails 5.0 upgrade. # # Read the Rails 5.0 release notes for more info on each option. # Enable per-form CSRF tokens. Previous versions had false. Rails.application.config.action_controller.per_form_csrf_tokens = true # Enable origin-checking CSRF mitigation. Previous versions had false. Rails.application.config.action_controller.forgery_protection_origin_check = true # Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`. # Previous versions had false. ActiveSupport.to_time_preserves_timezone = true # Require `belongs_to` associations by default. Previous versions had false. Rails.application.config.active_record.belongs_to_required_by_default = true # Do not halt callback chains when a callback returns false. Previous versions had true. ActiveSupport.halt_callback_chains_on_return_false = false # Configure SSL options to enable HSTS with subdomains. Previous versions had false. Rails.application.config.ssl_options = { hsts: { subdomains: true } }
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/wrap_parameters.rb
example/example/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/inflections.rb
example/example/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/cookies_serializer.rb
example/example/config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. # Specify a serializer for the signed and encrypted cookie jars. # Valid options are :json, :marshal, and :hybrid. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/assets.rb
example/example/config/initializers/assets.rb
# Be sure to restart your server when you modify this file. # Version of your assets, change this if you want to expire all your assets. Rails.application.config.assets.version = '1.0' # Add additional assets to the asset load path # Rails.application.config.assets.paths << Emoji.images_path # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js )
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/backtrace_silencers.rb
example/example/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/initializers/mime_types.rb
example/example/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/environments/test.rb
example/example/config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure public file server for tests with Cache-Control for performance. config.public_file_server.enabled = true config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=3600' } # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false config.action_mailer.perform_caching = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/environments/development.rb
example/example/config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports. config.consider_all_requests_local = true # Enable/disable caching. By default caching is disabled. if Rails.root.join('tmp/caching-dev.txt').exist? config.action_controller.perform_caching = true config.cache_store = :memory_store config.public_file_server.headers = { 'Cache-Control' => 'public, max-age=172800' } else config.action_controller.perform_caching = false config.cache_store = :null_store end # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false config.action_mailer.perform_caching = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Suppress logger output for asset requests. config.assets.quiet = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true # Use an evented file watcher to asynchronously detect changes in source code, # routes, locales, etc. This feature depends on the listen gem. config.file_watcher = ActiveSupport::EventedFileUpdateChecker end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/example/config/environments/production.rb
example/example/config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Disable serving static files from the `/public` folder by default since # Apache or NGINX already handles this. config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = 'http://assets.example.com' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX # Mount Action Cable outside main process or domain # config.action_cable.mount_path = nil # config.action_cable.url = 'wss://example.com/cable' # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Use the lowest log level to ensure availability of diagnostic information # when problems arise. config.log_level = :debug # Prepend all log lines with the following tags. config.log_tags = [ :request_id ] # Use a different cache store in production. # config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment) # config.active_job.queue_adapter = :resque # config.active_job.queue_name_prefix = "example_#{Rails.env}" config.action_mailer.perform_caching = false # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Use a different logger for distributed setups. # require 'syslog/logger' # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') if ENV["RAILS_LOG_TO_STDOUT"].present? logger = ActiveSupport::Logger.new(STDOUT) logger.formatter = config.log_formatter config.logger = ActiveSupport::TaggedLogging.new(logger) end # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/helpers/books_helper.rb
example/rails4/app/helpers/books_helper.rb
module BooksHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/helpers/articles_helper.rb
example/rails4/app/helpers/articles_helper.rb
module ArticlesHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/helpers/application_helper.rb
example/rails4/app/helpers/application_helper.rb
module ApplicationHelper end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/controllers/articles_controller.rb
example/rails4/app/controllers/articles_controller.rb
class ArticlesController < ApplicationController before_action :set_article, only: [:show, :edit, :update, :destroy] # GET /articles # GET /articles.json def index @articles = Article.all end # GET /articles/1 # GET /articles/1.json def show end # GET /articles/new def new @article = Article.new end # GET /articles/1/edit def edit end # POST /articles # POST /articles.json def create @article = Article.new(article_params) respond_to do |format| if @article.save format.html { redirect_to @article, notice: 'Article was successfully created.' } format.json { render :show, status: :created, location: @article } else format.html { render :new } format.json { render json: @article.errors, status: :unprocessable_entity } end end end # PATCH/PUT /articles/1 # PATCH/PUT /articles/1.json def update respond_to do |format| if @article.update(article_params) format.html { redirect_to @article, notice: 'Article was successfully updated.' } format.json { render :show, status: :ok, location: @article } else format.html { render :edit } format.json { render json: @article.errors, status: :unprocessable_entity } end end end # DELETE /articles/1 # DELETE /articles/1.json def destroy @article.destroy respond_to do |format| format.html { redirect_to articles_url, notice: 'Article was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_article @article = Article.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def article_params params.require(:article).permit(:title) end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/controllers/books_controller.rb
example/rails4/app/controllers/books_controller.rb
class BooksController < ApplicationController before_action :set_book, only: [:show, :edit, :update, :destroy] # GET /books # GET /books.json def index @books = Book.all end # GET /books/1 # GET /books/1.json def show end # GET /books/new def new @book = Book.new end # GET /books/1/edit def edit end # POST /books # POST /books.json def create @book = Book.new(book_params) respond_to do |format| if @book.save format.html { redirect_to @book, notice: 'Book was successfully created.' } format.json { render :show, status: :created, location: @book } else format.html { render :new } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # PATCH/PUT /books/1 # PATCH/PUT /books/1.json def update respond_to do |format| if @book.update(book_params) format.html { redirect_to @book, notice: 'Book was successfully updated.' } format.json { render :show, status: :ok, location: @book } else format.html { render :edit } format.json { render json: @book.errors, status: :unprocessable_entity } end end end # DELETE /books/1 # DELETE /books/1.json def destroy @book.destroy respond_to do |format| format.html { redirect_to books_url, notice: 'Book was successfully destroyed.' } format.json { head :no_content } end end private # Use callbacks to share common setup or constraints between actions. def set_book @book = Book.find(params[:id]) end # Never trust parameters from the scary internet, only allow the white list through. def book_params params.require(:book).permit(:title) end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/controllers/application_controller.rb
example/rails4/app/controllers/application_controller.rb
class ApplicationController < ActionController::Base # Prevent CSRF attacks by raising an exception. # For APIs, you may want to use :null_session instead. protect_from_forgery with: :exception end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/models/book.rb
example/rails4/app/models/book.rb
class Book < ActiveRecord::Base end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/app/models/article.rb
example/rails4/app/models/article.rb
class Article < ActiveRecord::Base end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/db/seeds.rb
example/rails4/db/seeds.rb
# This file should contain all the record creation needed to seed the database with its default values. # The data can then be loaded with the rake db:seed (or created alongside the db with db:setup). # # Examples: # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first)
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/db/schema.rb
example/rails4/db/schema.rb
# encoding: UTF-8 # This file is auto-generated from the current state of the database. Instead # of editing this file, please use the migrations feature of Active Record to # incrementally modify your database, and then regenerate this schema definition. # # Note that this schema.rb definition is the authoritative source for your # database schema. If you need to create the application database on another # system, you should be using db:schema:load, not running all the migrations # from scratch. The latter is a flawed and unsustainable approach (the more migrations # you'll amass, the slower it'll run and the greater likelihood for issues). # # It's strongly recommended that you check this file into your version control system. ActiveRecord::Schema.define(version: 20140623044357) do create_table "articles", force: true do |t| t.string "title" t.datetime "created_at" t.datetime "updated_at" end create_table "books", force: true do |t| t.string "title" t.datetime "created_at" t.datetime "updated_at" end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/db/migrate/20140623044349_create_books.rb
example/rails4/db/migrate/20140623044349_create_books.rb
class CreateBooks < ActiveRecord::Migration def change create_table :books do |t| t.string :title t.timestamps end end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/db/migrate/20140623044357_create_articles.rb
example/rails4/db/migrate/20140623044357_create_articles.rb
class CreateArticles < ActiveRecord::Migration def change create_table :articles do |t| t.string :title t.timestamps end end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/test_helper.rb
example/rails4/test/test_helper.rb
ENV['RAILS_ENV'] ||= 'test' require File.expand_path('../../config/environment', __FILE__) require 'rails/test_help' class ActiveSupport::TestCase # Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order. # # Note: You'll currently still have to declare fixtures explicitly in integration tests # -- they do not yet inherit this setting fixtures :all # Add more helper methods to be used by all tests here... end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/helpers/articles_helper_test.rb
example/rails4/test/helpers/articles_helper_test.rb
require 'test_helper' class ArticlesHelperTest < ActionView::TestCase end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/helpers/books_helper_test.rb
example/rails4/test/helpers/books_helper_test.rb
require 'test_helper' class BooksHelperTest < ActionView::TestCase end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/controllers/books_controller_test.rb
example/rails4/test/controllers/books_controller_test.rb
require 'test_helper' class BooksControllerTest < ActionController::TestCase setup do @book = books(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:books) end test "should get new" do get :new assert_response :success end test "should create book" do assert_difference('Book.count') do post :create, book: { title: @book.title } end assert_redirected_to book_path(assigns(:book)) end test "should show book" do get :show, id: @book assert_response :success end test "should get edit" do get :edit, id: @book assert_response :success end test "should update book" do patch :update, id: @book, book: { title: @book.title } assert_redirected_to book_path(assigns(:book)) end test "should destroy book" do assert_difference('Book.count', -1) do delete :destroy, id: @book end assert_redirected_to books_path end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/controllers/articles_controller_test.rb
example/rails4/test/controllers/articles_controller_test.rb
require 'test_helper' class ArticlesControllerTest < ActionController::TestCase setup do @article = articles(:one) end test "should get index" do get :index assert_response :success assert_not_nil assigns(:articles) end test "should get new" do get :new assert_response :success end test "should create article" do assert_difference('Article.count') do post :create, article: { title: @article.title } end assert_redirected_to article_path(assigns(:article)) end test "should show article" do get :show, id: @article assert_response :success end test "should get edit" do get :edit, id: @article assert_response :success end test "should update article" do patch :update, id: @article, article: { title: @article.title } assert_redirected_to article_path(assigns(:article)) end test "should destroy article" do assert_difference('Article.count', -1) do delete :destroy, id: @article end assert_redirected_to articles_path end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/models/article_test.rb
example/rails4/test/models/article_test.rb
require 'test_helper' class ArticleTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/test/models/book_test.rb
example/rails4/test/models/book_test.rb
require 'test_helper' class BookTest < ActiveSupport::TestCase # test "the truth" do # assert true # end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/application.rb
example/rails4/config/application.rb
require File.expand_path('../boot', __FILE__) require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) module Blog class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded. # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s] # config.i18n.default_locale = :de config.autoload_paths += %W(#{config.root}/lib) config.middleware.swap ActiveRecord::ConnectionAdapters::ConnectionManagement, "ActiveRecord::ConnectionAdapters::RefreshConnectionManagement" end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/environment.rb
example/rails4/config/environment.rb
# Load the Rails application. require File.expand_path('../application', __FILE__) # Initialize the Rails application. Rails.application.initialize!
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/routes.rb
example/rails4/config/routes.rb
Rails.application.routes.draw do resources :articles resources :books # The priority is based upon order of creation: first created -> highest priority. # See how all your routes lay out with "rake routes". # You can have the root of your site routed with "root" # root 'welcome#index' # Example of regular route: # get 'products/:id' => 'catalog#view' # Example of named route that can be invoked with purchase_url(id: product.id) # get 'products/:id/purchase' => 'catalog#purchase', as: :purchase # Example resource route (maps HTTP verbs to controller actions automatically): # resources :products # Example resource route with options: # resources :products do # member do # get 'short' # post 'toggle' # end # # collection do # get 'sold' # end # end # Example resource route with sub-resources: # resources :products do # resources :comments, :sales # resource :seller # end # Example resource route with more complex sub-resources: # resources :products do # resources :comments # resources :sales do # get 'recent', on: :collection # end # end # Example resource route with concerns: # concern :toggleable do # post 'toggle' # end # resources :posts, concerns: :toggleable # resources :photos, concerns: :toggleable # Example resource route within a namespace: # namespace :admin do # # Directs /admin/products/* to Admin::ProductsController # # (app/controllers/admin/products_controller.rb) # resources :products # end end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/boot.rb
example/rails4/config/boot.rb
# Set up gems listed in the Gemfile. ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/filter_parameter_logging.rb
example/rails4/config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [:password]
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/session_store.rb
example/rails4/config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: '_blog_session'
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/wrap_parameters.rb
example/rails4/config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters format: [:json] if respond_to?(:wrap_parameters) end # To enable root element in JSON for ActiveRecord objects. # ActiveSupport.on_load(:active_record) do # self.include_root_in_json = true # end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/inflections.rb
example/rails4/config/initializers/inflections.rb
# Be sure to restart your server when you modify this file. # Add new inflection rules using the following format. Inflections # are locale specific, and you may define rules for as many different # locales as you wish. All of these examples are active by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.plural /^(ox)$/i, '\1en' # inflect.singular /^(ox)en/i, '\1' # inflect.irregular 'person', 'people' # inflect.uncountable %w( fish sheep ) # end # These inflection rules are supported but not enabled by default: # ActiveSupport::Inflector.inflections(:en) do |inflect| # inflect.acronym 'RESTful' # end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/cookies_serializer.rb
example/rails4/config/initializers/cookies_serializer.rb
# Be sure to restart your server when you modify this file. Rails.application.config.action_dispatch.cookies_serializer = :json
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/backtrace_silencers.rb
example/rails4/config/initializers/backtrace_silencers.rb
# Be sure to restart your server when you modify this file. # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. # Rails.backtrace_cleaner.remove_silencers!
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/initializers/mime_types.rb
example/rails4/config/initializers/mime_types.rb
# Be sure to restart your server when you modify this file. # Add new mime types for use in respond_to blocks: # Mime::Type.register "text/richtext", :rtf
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/environments/test.rb
example/rails4/config/environments/test.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # The test environment is used exclusively to run your application's # test suite. You never need to work with it otherwise. Remember that # your test database is "scratch space" for the test suite and is wiped # and recreated between test runs. Don't rely on the data there! config.cache_classes = true # Do not eager load code on boot. This avoids loading your whole application # just for the purpose of running a single test. If you are using a tool that # preloads Rails for running tests, you may have to set it to true. config.eager_load = false # Configure static asset server for tests with Cache-Control for performance. config.serve_static_assets = true config.static_cache_control = 'public, max-age=3600' # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Raise exceptions instead of rendering exception templates. config.action_dispatch.show_exceptions = false # Disable request forgery protection in test environment. config.action_controller.allow_forgery_protection = false # Tell Action Mailer not to deliver emails to the real world. # The :test delivery method accumulates sent emails in the # ActionMailer::Base.deliveries array. config.action_mailer.delivery_method = :test # Print deprecation notices to the stderr. config.active_support.deprecation = :stderr # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/environments/development.rb
example/rails4/config/environments/development.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # In the development environment your application's code is reloaded on # every request. This slows down response time but is perfect for development # since you don't have to restart the web server when you make code changes. config.cache_classes = false # Do not eager load code on boot. config.eager_load = false # Show full error reports and disable caching. config.consider_all_requests_local = true config.action_controller.perform_caching = false # Don't care if the mailer can't send. config.action_mailer.raise_delivery_errors = false # Print deprecation notices to the Rails logger. config.active_support.deprecation = :log # Raise an error on page load if there are pending migrations. config.active_record.migration_error = :page_load # Debug mode disables concatenation and preprocessing of assets. # This option may cause significant delays in view rendering with a large # number of complex assets. config.assets.debug = true # Adds additional error checking when serving assets at runtime. # Checks for improperly declared sprockets dependencies. # Raises helpful error messages. config.assets.raise_runtime_errors = true # Raises error for missing translations # config.action_view.raise_on_missing_translations = true end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false
sonots/activerecord-refresh_connection
https://github.com/sonots/activerecord-refresh_connection/blob/5f5a742f2feae8e5fbbce1576ef4b72d81e073e4/example/rails4/config/environments/production.rb
example/rails4/config/environments/production.rb
Rails.application.configure do # Settings specified here will take precedence over those in config/application.rb. # Code is not reloaded between requests. config.cache_classes = true # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both threaded web servers # and those relying on copy on write to perform better. # Rake tasks automatically ignore this option for performance. config.eager_load = true # Full error reports are disabled and caching is turned on. config.consider_all_requests_local = false config.action_controller.perform_caching = true # Enable Rack::Cache to put a simple HTTP cache in front of your application # Add `rack-cache` to your Gemfile before enabling this. # For large-scale production use, consider using a caching reverse proxy like nginx, varnish or squid. # config.action_dispatch.rack_cache = true # Disable Rails's static asset server (Apache or nginx will already do this). config.serve_static_assets = false # Compress JavaScripts and CSS. config.assets.js_compressor = :uglifier # config.assets.css_compressor = :sass # Do not fallback to assets pipeline if a precompiled asset is missed. config.assets.compile = false # Generate digests for assets URLs. config.assets.digest = true # Version of your assets, change this if you want to expire all your assets. config.assets.version = '1.0' # Specifies the header that your server uses for sending files. # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. # config.force_ssl = true # Set to :debug to see everything in the log. config.log_level = :info # Prepend all log lines with the following tags. # config.log_tags = [ :subdomain, :uuid ] # Use a different logger for distributed setups. # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new) # Use a different cache store in production. # config.cache_store = :mem_cache_store # Enable serving of images, stylesheets, and JavaScripts from an asset server. # config.action_controller.asset_host = "http://assets.example.com" # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # config.assets.precompile += %w( search.js ) # Ignore bad email addresses and do not raise email delivery errors. # Set this to true and configure the email server for immediate delivery to raise delivery errors. # config.action_mailer.raise_delivery_errors = false # Enable locale fallbacks for I18n (makes lookups for any locale fall back to # the I18n.default_locale when a translation cannot be found). config.i18n.fallbacks = true # Send deprecation notices to registered listeners. config.active_support.deprecation = :notify # Disable automatic flushing of the log to improve performance. # config.autoflush_log = false # Use default logging formatter so that PID and timestamp are not suppressed. config.log_formatter = ::Logger::Formatter.new # Do not dump schema after migrations. config.active_record.dump_schema_after_migration = false end
ruby
MIT
5f5a742f2feae8e5fbbce1576ef4b72d81e073e4
2026-01-04T17:48:56.747439Z
false