Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

add missing mongoid types

  • Loading branch information...
commit 238291ba20203d0166a2b78e7df6d6a10ff1f747 1 parent 4e6ede2
fjg fjg authored committed
2  app/views/rails_admin/main/_bson_object_id.html.erb
... ... @@ -0,0 +1,2 @@
  1 + <%= label_tag "#{field.abstract_model.to_param}_#{field.name}", field.label %>
  2 + <%= text_field field.abstract_model.to_param, field.name, :size => [field.length].min, :maxlength => field.length, :class => "#{field.css_class} #{field.has_errors? ? "errorField" : nil}", :value => field.value %>
28 lib/rails_admin/adapters/mongoid.rb
@@ -139,27 +139,39 @@ def properties
139 139 @properties if @properties
140 140 @properties = model.fields.map do |name,field|
141 141 ar_type = case field.type.to_s
142   - when 'BSON::ObjectId'
  142 + when "Array"
143 143 :string
144   - when "String"
  144 + when "Array"
145 145 :string
146   - when "Integer"
147   - :integer
148   - when "DateTime"
  146 + when "BigDecimal"
  147 + :string
  148 + when "Boolean"
  149 + :boolean
  150 + when "Date"
149 151 :datetime
150   - when "Time"
  152 + when "DateTime"
151 153 :datetime
152 154 when "Float"
153 155 :float
154   - when "Array"
  156 + when "Hash"
  157 + :string
  158 + when "Integer"
  159 + :integer
  160 + when "String"
155 161 :string
  162 + when "Time"
  163 + :datetime
  164 + when "BSON::ObjectId"
  165 + :bson_object_id
  166 + when "Object"
  167 + :bson_object_id
156 168 else
157 169 raise "Need to map field #{field.type.to_s} for field name #{name} in #{model.inspect}"
158 170 end
159 171
160 172 {
161 173 :name => field.name.to_sym,
162   - :pretty_name => field.name.to_s.gsub('_', ' ').capitalize,
  174 + :pretty_name => field.name.to_s.gsub('_', ' ').strip.capitalize,
163 175 :type => ar_type,
164 176 :length => 1024,
165 177 :nullable? => true,
1  lib/rails_admin/config/fields/types/all.rb
... ... @@ -1,5 +1,6 @@
1 1 require 'rails_admin/config/fields/types/belongs_to_association'
2 2 require 'rails_admin/config/fields/types/boolean'
  3 +require 'rails_admin/config/fields/types/bson_object_id'
3 4 require 'rails_admin/config/fields/types/date'
4 5 require 'rails_admin/config/fields/types/datetime'
5 6 require 'rails_admin/config/fields/types/decimal'
25 lib/rails_admin/config/fields/types/bson_object_id.rb
... ... @@ -0,0 +1,25 @@
  1 +require 'rails_admin/config/fields/base'
  2 +
  3 +module RailsAdmin
  4 + module Config
  5 + module Fields
  6 + module Types
  7 + class BsonObjectId < RailsAdmin::Config::Fields::Base
  8 + # Register field type for the type loader
  9 + RailsAdmin::Config::Fields::Types::register(self)
  10 +
  11 + register_instance_option(:column_width) do
  12 + 100
  13 + end
  14 +
  15 + register_instance_option(:help) do
  16 + "BSON::ObjectId"
  17 + end
  18 + end
  19 + end
  20 + end
  21 + end
  22 +end
  23 +
  24 +
  25 +

0 comments on commit 238291b

Please sign in to comment.
Something went wrong with that request. Please try again.