Skip to content

Commit

Permalink
The model cannot be validated if it is preloaded and the attribute/co…
Browse files Browse the repository at this point in the history
…lumn is not in the database (migration still not runned). Ususally 'test' and 'production' environments.
  • Loading branch information
Nicolas Fouché authored and Bruce Williams committed Dec 15, 2009
1 parent 7dcd0f4 commit ead030d
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/bitmask_attribute.rb
Expand Up @@ -25,6 +25,10 @@ def install_on(model)
#######

def validate_for(model)
# The model cannot be validated if it is preloaded and the attribute/column is not in the
# database (migration still not runned). Ususally 'test' and 'production' environments.
return if defined?(Rails) && Rails.configuration.cache_classes

unless model.columns.detect { |col| col.name == attribute.to_s }
raise ArgumentError, "`#{attribute}' is not an attribute of `#{model}'"
end
Expand Down

0 comments on commit ead030d

Please sign in to comment.