From c751ad2231a9491fe7ae404e87ed337a7597935a Mon Sep 17 00:00:00 2001 From: Nicolae Claudius Date: Mon, 30 Jan 2012 13:11:23 -0800 Subject: [PATCH] fixes for staging, cleanup --- Gemfile.lock | 2 +- config/initializers/as_r32_compat.rb | 36 --------------------------- config/initializers/as_rake_fix.rb.rb | 6 +++++ db/samples.rb | 4 ++- db/seeds.rb | 8 ++++-- 5 files changed, 16 insertions(+), 40 deletions(-) delete mode 100644 config/initializers/as_r32_compat.rb create mode 100644 config/initializers/as_rake_fix.rb.rb diff --git a/Gemfile.lock b/Gemfile.lock index f244655..d8b1153 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,7 +6,7 @@ GIT GIT remote: https://github.com/activescaffold/active_scaffold.git - revision: 1fb6598311db7807b665b356f7113a3b386394df + revision: 090aaf46e046534d64bf3d2ccf3671e26fc1995e specs: active_scaffold (3.1.18) rails (>= 3.1.3) diff --git a/config/initializers/as_r32_compat.rb b/config/initializers/as_r32_compat.rb deleted file mode 100644 index 7cf2641..0000000 --- a/config/initializers/as_r32_compat.rb +++ /dev/null @@ -1,36 +0,0 @@ -module ActionView - class LookupContext - module ViewPaths - def find_all_templates(name, partial = false, locals = {}) - prefixes.collect do |prefix| - view_paths.collect do |resolver| - temp_args = *args_for_lookup(name, [prefix], partial, locals, {}) - temp_args[1] = temp_args[1][0] - resolver.find_all(*temp_args) - end - end.flatten! - end - end - end -end - -# Bugfix: building an sti model from an association fails -# https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/6306-collection-associations-build-method-not-supported-for-sti -# https://github.com/rails/rails/issues/815 -# https://github.com/rails/rails/pull/1686 -ActiveRecord::Reflection::AssociationReflection.class_eval do - def klass_with_sti(*opts) - sti_col = klass.inheritance_column - if sti_col and (h = opts.first).is_a? Hash and (passed_type = ( h[sti_col] || h[sti_col.to_sym] )) and (new_klass = active_record.send(:compute_type, passed_type)) < klass - new_klass - else - klass - end - end - def build_association(*opts, &block) - klass_with_sti(*opts).new(*opts, &block) - end - def create_association(*opts, &block) - klass_with_sti(*opts).create(*opts, &block) - end -end diff --git a/config/initializers/as_rake_fix.rb.rb b/config/initializers/as_rake_fix.rb.rb new file mode 100644 index 0000000..ece4743 --- /dev/null +++ b/config/initializers/as_rake_fix.rb.rb @@ -0,0 +1,6 @@ +# https://github.com/activescaffold/active_scaffold/issues/131 +class ApplicationController < ActionController::Base + def self.active_scaffold(*, &_) + super unless (File.basename($0) == "rake" && ARGV.include?("db:migrate")) + end +end \ No newline at end of file diff --git a/db/samples.rb b/db/samples.rb index 16bfdb5..e977055 100644 --- a/db/samples.rb +++ b/db/samples.rb @@ -2,13 +2,15 @@ users = [User.find_by_email('user@entrydns.net')] for i in 1..5 do name = "user#{i}" - user = User.create!( + user = User.new( :first_name => name, :last_name => name, :email => "#{name}@entrydns.net", :password => 'useruser', :password_confirmation => 'useruser' ) + user.confirmed_at = Time.now + user.save! user.confirm! users << user unless i > 3 end diff --git a/db/seeds.rb b/db/seeds.rb index 78fe7c2..7246dfa 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -1,11 +1,13 @@ # an user for administrative purposes -admin = User.create!( +admin = User.new( :first_name => 'admin', :last_name => 'admin', :email => 'admin@entrydns.net', :password => 'garlik1', :password_confirmation => 'garlik1' ) +admin.confirmed_at = Time.now +admin.save! admin.confirm! for name in Settings.host_domains @@ -15,11 +17,13 @@ for name in Settings.host_domains end # sample user -user = User.create!( +user = User.new( :first_name => 'user', :last_name => 'user', :email => 'user@entrydns.net', :password => 'useruser', :password_confirmation => 'useruser' ) +user.confirmed_at = Time.now +user.save! user.confirm!