lib/generators/active_leonardo.rb in active_leonardo-0.1.0 vs lib/generators/active_leonardo.rb in active_leonardo-0.2.0
- old
+ new
@@ -47,16 +47,22 @@
end
value = case attribute.type
when :boolean then "true"
when :integer then "#"
when :float, :decimal then "#.46"
- when :references, :belongs_to then "#"
+ when :references, :belongs_to then "rand(#{attribute.name}_from..#{attribute.name}_to)"
when :date then "#{Time.now.strftime("%Y-%m-%d 00:00:00.000")}".inspect
when :datetime then "#{Time.now.strftime("%Y-%m-%d %H:%M:%S.000")}".inspect
when :time, :timestamp then "#{Time.now.strftime("%H:%M:%S.000")}".inspect
else "#{attribute.name.titleize}\#".inspect
end
" #{name} => #{value}"
+ end
+ def attribute_to_range(attribute)
+ case attribute.type
+ when :references, :belongs_to then "#{attribute.name}_from = #{attribute.name.classify}.first.id; #{attribute.name}_to = #{attribute.name.classify}.last.id#{CRLF}"
+ else ""
+ end
end
def attribute_to_factories(attribute)
spaces = 34
space_association = " " * (spaces-11).abs
space_sequence = " " * (spaces-attribute.name.size-11).abs
\ No newline at end of file