rails_extensions 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,21 @@
1
+ module ActionController
2
+ class AbstractRequest
3
+
4
+ def full_host
5
+ if self.port == self.standard_port
6
+ self.host
7
+ else
8
+ self.host_with_port
9
+ end
10
+ end
11
+
12
+ def full_sub_path
13
+ self.protocol + self.full_host
14
+ end
15
+
16
+ def full_path
17
+ self.full_sub_path + self.request_uri
18
+ end
19
+
20
+ end
21
+ end
@@ -0,0 +1,33 @@
1
+ module ActiveRecord
2
+ module Associations
3
+ module ClassMethods
4
+ # fixes a bug with ActiveRecord, see http://dev.rubyonrails.org/ticket/7570
5
+ def has_and_belongs_to_many(association_id, options = {}, &extension)
6
+ reflection = create_has_and_belongs_to_many_reflection(association_id, options, &extension)
7
+
8
+ add_multiple_associated_save_callbacks(reflection.name)
9
+ collection_accessor_methods(reflection, HasAndBelongsToManyAssociation)
10
+
11
+ # Don't use a before_destroy callback since users' before_destroy
12
+ # callbacks will be executed after the association is wiped out.
13
+ old_method = "destroy_without_habtm_shim_for_#{reflection.name}"
14
+ ##class_eval <<-end_eval
15
+ class_eval <<-end_eval unless method_defined?(old_method)
16
+ alias_method :#{old_method}, :destroy_without_callbacks
17
+ def destroy_without_callbacks
18
+ #{reflection.name}.clear
19
+ #{old_method}
20
+ end
21
+ end_eval
22
+
23
+ add_association_callbacks(reflection.name, options)
24
+
25
+ # deprecated api
26
+ deprecated_collection_count_method(reflection.name)
27
+ deprecated_add_association_relation(reflection.name)
28
+ deprecated_remove_association_relation(reflection.name)
29
+ deprecated_has_collection_method(reflection.name)
30
+ end
31
+ end
32
+ end
33
+ end
@@ -9,6 +9,11 @@ class ActiveRecord::Base
9
9
  if self.respond_to?(:deleted_at)
10
10
  return !self.deleted_at.nil?
11
11
  end
12
+ if self.respond_to?(:status)
13
+ if Status.respond_to?(:deleted)
14
+ return self.status == Status.deleted
15
+ end
16
+ end
12
17
  false
13
18
  end
14
19
 
@@ -37,4 +42,28 @@ class << ActiveRecord::Base
37
42
  self.find(:first, options)
38
43
  end
39
44
 
45
+ def last(options = {})
46
+ options = {:order => "id desc"}.merge(options)
47
+ self.first(options)
48
+ end
49
+
50
+ alias_method :old_establish_connection, :establish_connection
51
+
52
+ def establish_connection(spec = nil)
53
+ new_spec = spec
54
+ if (spec.is_a? String) || (spec.is_a? Symbol)
55
+ new_spec = spec.to_s
56
+ appended = false
57
+ ['production', 'test', 'development'].each do |env|
58
+ if new_spec =~ /#{env}$/
59
+ appended = true
60
+ break
61
+ end
62
+ end
63
+
64
+ new_spec = new_spec + "_#{RAILS_ENV}" unless appended
65
+ end
66
+ self.old_establish_connection(new_spec)
67
+ end
68
+
40
69
  end
data/lib/m_cookies.rb ADDED
@@ -0,0 +1,14 @@
1
+ module ActionController
2
+ class CookieJar
3
+ alias_method :old_setter, :[]=
4
+
5
+ def []=(name, options)
6
+ options = {:value => options} unless options.is_a? Hash
7
+ if self.respond_to?(:app_config)
8
+ options = {:domain => app_config.cookie_domain}.merge(options) unless app_config.cookie_domain.nil?
9
+ end
10
+ old_setter(name, options)
11
+ end
12
+
13
+ end
14
+ end
@@ -0,0 +1,4 @@
1
+ class MigrationModel < ActiveRecord::Base
2
+ self.abstract_class = true
3
+
4
+ end
@@ -2,4 +2,4 @@
2
2
  gem_name: rails_extensions
3
3
  package: rails_extensions
4
4
  project: magrathea
5
- version: 1.0.0
5
+ version: 1.0.1
metadata CHANGED
@@ -3,8 +3,8 @@ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: rails_extensions
5
5
  version: !ruby/object:Gem::Version
6
- version: 1.0.0
7
- date: 2007-09-13 00:00:00 -04:00
6
+ version: 1.0.1
7
+ date: 2007-10-19 00:00:00 -04:00
8
8
  summary: rails_extensions
9
9
  require_paths:
10
10
  - lib
@@ -17,8 +17,14 @@ rubyforge_project: magrathea
17
17
  description: "rails_extensions was developed by: markbates"
18
18
  autorequire:
19
19
  - rails_extensions
20
+ - m_migration_model
20
21
  - m_form_tag_helper
22
+ - m_cookies
21
23
  - m_active_record_base
24
+ - m_active_record_associatioins
25
+ - m_abstract_request
26
+ - rails_extensions
27
+ - m_migration_model
22
28
  - m_form_tag_helper
23
29
  - m_active_record_base
24
30
  default_executable:
@@ -38,8 +44,12 @@ authors:
38
44
  - markbates
39
45
  files:
40
46
  - init.rb
47
+ - lib/m_abstract_request.rb
48
+ - lib/m_active_record_associatioins.rb
41
49
  - lib/m_active_record_base.rb
50
+ - lib/m_cookies.rb
42
51
  - lib/m_form_tag_helper.rb
52
+ - lib/m_migration_model.rb
43
53
  - lib/rails_extensions.rb
44
54
  - lib/tasks/rubyforge_config.yml
45
55
  test_files: []