Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jgoizueta/modalfields
base: 8793143cc8
...
head fork: jgoizueta/modalfields
compare: 975e23acfa
  • 5 commits
  • 4 files changed
  • 0 commit comments
  • 1 contributor
View
2  VERSION
@@ -1 +1 @@
-1.1.1
+1.1.2
View
9 lib/modalfields/modalfields.rb
@@ -263,7 +263,10 @@ def map_column_to_field_declaration(column)
def diff(model)
# model.columns will fail if the table does not exist
existing_fields = model.columns rescue []
- association_fields = model.reflect_on_all_associations(:belongs_to).map(&:primary_key_name).flatten.map(&:to_s)
+ # up to ActiveRecord 3.1 we had primary_key_name in AssociationReflection; not itis foreign_key
+ association_fields = model.reflect_on_all_associations(:belongs_to).map{ |r|
+ r.respond_to?(:primary_key_name) ? r.primary_key_name : r.foreign_key
+ }.flatten.map(&:to_s)
pk_fields = Array(model.primary_key).map(&:to_s)
case show_primary_keys
when true
@@ -300,11 +303,11 @@ def diff(model)
attr_keys = attrs.keys
decl_attrs = attr_keys.map{|a|
v = field_declaration.attributes[a]
- v==attrs[a] ? nil : v
+ v==attrs[a] ? nil : (v==false ? nil : v)
}
col_attrs = attr_keys.map{|a|
v = column.attributes[a]
- v==attrs[a] ? nil : v
+ v==attrs[a] ? nil : (v==false ? nil : v)
}
if decl_attrs == col_attrs
identical=true
View
5 modalfields.gemspec
@@ -5,11 +5,11 @@
Gem::Specification.new do |s|
s.name = "modalfields"
- s.version = "1.1.1"
+ s.version = "1.1.2"
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Javier Goizueta"]
- s.date = "2012-04-18"
+ s.date = "2012-04-24"
s.description = "ModelFields is a Rails plugin that adds fields declarations to your models."
s.email = "jgoizueta@gmail.com"
s.extra_rdoc_files = [
@@ -33,6 +33,7 @@ Gem::Specification.new do |s|
"lib/tasks/check.rake",
"lib/tasks/migrate.rake",
"lib/tasks/update.rake",
+ "modalfields.gemspec",
"test/create_database.rb",
"test/database.yml",
"test/helper.rb",
View
20 test/helper.rb
@@ -24,21 +24,24 @@ class Test::Unit::TestCase
ENV['RAILS_ENV'] = 'test'
ENV['RAILS_ROOT'] ||= File.dirname(__FILE__) # + '/../../../..'
-
+
# require File.expand_path(File.join(ENV['RAILS_ROOT'], 'config/environment.rb'))
module Rails
def self.root
ENV['RAILS_ROOT']
end
+ def version
+ ActiveRecord::VERSION::STRING
+ end
end
-
+
def load_schema
config = YAML::load(IO.read(File.dirname(__FILE__) + '/database.yml')).with_indifferent_access
ActiveRecord::Base.logger = Logger.new(File.dirname(__FILE__) + "/debug.log")
-
+
db_adapter = ENV['DB']
-
+
# no db passed, try one of these fine config-free DBs before bombing.
db_adapter ||=
begin
@@ -47,15 +50,16 @@ def load_schema
'sqlite3'
rescue MissingSourceFile
end
-
+
if db_adapter.nil?
raise "No DB Adapter selected. Pass the DB= option to pick one, or install Sqlite3."
end
-
+
require File.dirname(__FILE__) + '/create_database'
create_database config[db_adapter]
-
+
ActiveRecord::Base.establish_connection(config[db_adapter])
load(File.dirname(__FILE__) + "/schema.rb")
- require File.dirname(__FILE__) + '/../rails/init'
+ require File.dirname(__FILE__) + '/../lib/modalfields'
+ ModalFields.enable
end

No commit comments for this range

Something went wrong with that request. Please try again.