Browse Source

fixes for staging, cleanup

pull/1/head
Nicolae Claudius 13 years ago
parent
commit
c751ad2231
  1. 2
      Gemfile.lock
  2. 36
      config/initializers/as_r32_compat.rb
  3. 6
      config/initializers/as_rake_fix.rb.rb
  4. 4
      db/samples.rb
  5. 8
      db/seeds.rb

2
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)

36
config/initializers/as_r32_compat.rb

@ -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

6
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

4
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

8
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!

Loading…
Cancel
Save