lib/padrino-gen/generators/components/orms/mongoid.rb in padrino-gen-0.10.5 vs lib/padrino-gen/generators/components/orms/mongoid.rb in padrino-gen-0.10.6.a
- old
+ new
@@ -51,11 +51,11 @@
# options => { :fields => ["title:string", "body:string"], :app => 'app' }
def create_model_file(name, options={})
model_path = destination_root(options[:app], 'models', "#{name.to_s.underscore}.rb")
field_tuples = options[:fields].map { |value| value.split(":") }
- column_declarations = field_tuples.map { |field, kind| "field :#{field}, :type => #{kind.camelize}" }.join("\n ")
- model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.camelize)
+ column_declarations = field_tuples.map { |field, kind| "field :#{field}, :type => #{kind.underscore.camelize}" }.join("\n ")
+ model_contents = MONGOID_MODEL.gsub(/!NAME!/, name.to_s.underscore.camelize)
model_contents.gsub!(/!FIELDS!/, column_declarations)
create_file(model_path, model_contents)
end
def create_model_migration(filename, name, fields)