Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion padrino-admin/README.rdoc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

Padrino has a beautiful Admin management dashboard with these features:

Orm Agnostic:: Data Adapters for Datamapper, Activerecord, Sequel, Mongomapper, Mongoid, Couchrest, Dynamoid
Orm Agnostic:: Data Adapters for Activerecord, Sequel, Mongoid, Ohm, Dynamoid
Template Agnostic:: Erb, Erubis and Haml Renderer
Authentication:: Support for Account authentication, Account Permission management
Scaffold:: You can simply create a new "admin interface" by providing a Model
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This ORM list is missing MiniRecord, which is still supported by the admin generator. Also, further down this README still references DataMapper-specific rake tasks (e.g., dm:migrate, dm:auto:migrate); those instructions should be updated/removed now that DataMapper support is being removed.

Copilot uses AI. Check for mistakes.
Expand Down
2 changes: 1 addition & 1 deletion padrino-admin/lib/padrino-admin.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ module Padrino
##
# Padrino::Admin is beautiful Ajax Admin, with these features:
#
# Orm Agnostic:: Adapters for datamapper, activerecord, mongomapper, couchdb (now only: datamapper and activerecord), ohm
# Orm Agnostic:: Adapters for activerecord, sequel, mongoid, ohm, and more
# Authentication:: Support for Account authentication, Account Permission management
# Scaffold:: You can simply create a new "admin interface" simply providing a Model
# Ajax Uploads:: You can upload file, manage them and attach them to any model in a quick and simple way (coming soon)
Expand Down
2 changes: 1 addition & 1 deletion padrino-admin/lib/padrino-admin/generators/actions.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def ext
# Tell us for now which orm we support
#
def supported_orm
%i[minirecord datamapper activerecord mongomapper mongoid couchrest sequel ohm dynamoid]
%i[minirecord activerecord mongoid sequel ohm dynamoid]
end

##
Expand Down
3 changes: 1 addition & 2 deletions padrino-admin/lib/padrino-admin/generators/admin_app.rb
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ def create_admin

unless options[:destroy]
insert_middleware 'ConnectionPoolManagement', @admin_path if %i[minirecord activerecord].include?(orm)
insert_middleware 'IdentityMap', @admin_path if orm == :datamapper
end

params = [
Expand Down Expand Up @@ -147,7 +146,7 @@ def create_admin

instructions = []
instructions << "Run 'bundle'"
if %i[activerecord datamapper sequel].include?(orm)
if %i[activerecord sequel].include?(orm)
instructions << "Run 'bundle exec rake db:create' if you have not created a database yet"
instructions << "Run 'bundle exec rake db:migrate'"
end
Expand Down
38 changes: 6 additions & 32 deletions padrino-admin/lib/padrino-admin/generators/orm.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ def activerecord?
end

def field_type(type)
type = :string if type.nil? # couchrest-Hack to avoid the next line to fail
type = :string if type.nil?
type = type.to_s.demodulize.downcase.to_sym unless type.is_a?(Symbol)

case type
Expand All @@ -52,36 +52,14 @@ def columns
case orm
when :activerecord then @klass.columns
when :minirecord then @klass.columns
when :datamapper then @klass.properties.map { |p| dm_column(p) }
when :couchrest then @klass.properties
when :mongoid then @klass.fields.values.reject { |col| %w[_id _type].include?(col.name) }
when :mongomapper then @klass.keys.values.reject { |key| key.name == '_id' } # On MongoMapper keys are an hash
when :sequel then @klass.db_schema.map { |k, v| v[:type] = :text if v[:db_type] =~ /^text/i; Column.new(k, v[:type]) }
when :ohm then @klass.attributes.map { |a| Column.new(a.to_s, :string) } # ohm has strings
when :dynamoid then @klass.attributes.map { |k, v| Column.new(k.to_s, v[:type]) }
else raise OrmError, "Adapter #{orm} is not yet supported!"
end
end

def dm_column(property)
case property
when DataMapper::Property::Text
Column.new(property.name, :text)
when DataMapper::Property::Boolean
Column.new(property.name, :boolean)
when DataMapper::Property::Integer
Column.new(property.name, :integer)
when DataMapper::Property::Decimal
Column.new(property.name, :decimal)
when DataMapper::Property::Float
Column.new(property.name, :float)
when DataMapper::Property::String
Column.new(property.name, :string)
else # if all fails, lets assume its string-ish
Column.new(property.name, :string)
end
end

def column_fields
excluded_columns = %w[created_at updated_at] << (orm == :mongoid ? '_id' : 'id')
column_fields = columns.dup
Expand All @@ -97,8 +75,7 @@ def all

def find(params = nil)
case orm
when :activerecord, :minirecord, :mongomapper, :mongoid, :dynamoid then "#{klass_name}.find(#{params})"
when :datamapper, :couchrest then "#{klass_name}.get(#{params})"
when :activerecord, :minirecord, :mongoid, :dynamoid then "#{klass_name}.find(#{params})"
when :sequel, :ohm then "#{klass_name}[#{params}]"
else raise OrmError, "Adapter #{orm} is not yet supported!"
end
Expand All @@ -118,8 +95,8 @@ def save

def update_attributes(params = nil)
case orm
when :mongomapper, :mongoid, :couchrest, :dynamoid then "@#{name_singular}.update_attributes(#{params})"
when :activerecord, :minirecord, :datamapper, :ohm then "@#{name_singular}.update(#{params})"
when :mongoid, :dynamoid then "@#{name_singular}.update_attributes(#{params})"
when :activerecord, :minirecord, :ohm then "@#{name_singular}.update(#{params})"
when :sequel then "@#{name_singular}.modified! && @#{name_singular}.update(#{params})"
else raise OrmError, "Adapter #{orm} is not yet supported!"
end
Expand All @@ -132,10 +109,8 @@ def destroy
def find_by_ids(params = nil)
case orm
when :ohm then "#{klass_name}.fetch(#{params})"
when :datamapper then "#{klass_name}.all(id: #{params})"
when :sequel then "#{klass_name}.where(id: #{params})"
when :mongoid then "#{klass_name}.find(#{params})"
when :couchrest then "#{klass_name}.all(keys: #{params})"
when :dynamoid then "#{klass_name}.find(#{params})"
else find(params)
end
Expand All @@ -145,15 +120,14 @@ def multiple_destroy(params = nil)
case orm
when :ohm then "#{params}.each(&:delete)"
when :sequel then "#{params}.destroy"
when :datamapper then "#{params}.destroy"
when :couchrest, :mongoid, :mongomapper, :dynamoid then "#{params}.each(&:destroy)"
when :mongoid, :dynamoid then "#{params}.each(&:destroy)"
else "#{klass_name}.destroy #{params}"
end
end

def has_error(field)
case orm
when :datamapper, :ohm, :sequel then "@#{name_singular}.errors.key?(:#{field}) && @#{name_singular}.errors[:#{field}].count > 0"
when :ohm, :sequel then "@#{name_singular}.errors.key?(:#{field}) && @#{name_singular}.errors[:#{field}].count > 0"
else "@#{name_singular}.errors.include?(:#{field})"
end
end
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<div class=base-icons>
<div class=btn-group>
<div class="btn btn-primary" title="Adapters for datamapper, sequel, activerecord, minirecord, mongomapper, mongoid, couchrest"><%%= tag_icon("cogs fa-2x", "Orm Agnostic") %></div>
<div class="btn btn-primary" title="Adapters for sequel, activerecord, minirecord, mongoid"><%%= tag_icon("cogs fa-2x", "Orm Agnostic") %></div>
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This tooltip enumerates supported ORMs but omits ohm and dynamoid, which are still supported by the admin generator. Update the title attribute to reflect the full supported set (or avoid hard-coding a list) so users aren’t misled.

Suggested change
<div class="btn btn-primary" title="Adapters for sequel, activerecord, minirecord, mongoid"><%%= tag_icon("cogs fa-2x", "Orm Agnostic") %></div>
<div class="btn btn-primary" title="Adapters for multiple Ruby ORMs"><%%= tag_icon("cogs fa-2x", "Orm Agnostic") %></div>

Copilot uses AI. Check for mistakes.
<div class="btn btn-success" title="User Authentication Support, User Authorization Management"><%%= tag_icon("group fa-2x", "Authentication") %></div>
<div class="btn btn-info" title="Erb, Haml, Slim Rendering Support"><%%= tag_icon("tasks fa-2x", "Template Agnostic") %></div>
<div class="btn btn-warning" title="English, German, Russian, Danish, French, Brazilian and Italian localizations and many more!.."><%%= tag_icon("flag fa-2x", "Multi Language") %></div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

.base-icons
.btn-group
.btn.btn-primary{title: 'Adapters for datamapper, sequel, activerecord, minirecord, mongomapper, mongoid, couchrest'}
.btn.btn-primary{title: 'Adapters for sequel, activerecord, minirecord, mongoid'}
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The tooltip text here lists supported ORMs but does not include ohm and dynamoid, which are in the current supported ORM list for the admin generator. Please update the list (or reword to avoid enumerating adapters) so the UI text stays accurate.

Suggested change
.btn.btn-primary{title: 'Adapters for sequel, activerecord, minirecord, mongoid'}
.btn.btn-primary{title: 'Adapters for multiple ORMs and data stores'}

Copilot uses AI. Check for mistakes.
= tag_icon('cogs fa-2x', 'Orm Agnostic')
.btn.btn-success{title: 'User Authentication Support, User Authorization Management'}
= tag_icon('group fa-2x', 'Authentication')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ div class="base-text"

div class="base-icons"
div class="btn-group"
div class="btn btn-primary" title="Adapters for datamapper, sequel, activerecord, minirecord, mongomapper, mongoid, couchrest" = tag_icon("cogs fa-2x", "Orm Agnostic")
div class="btn btn-primary" title="Adapters for sequel, activerecord, minirecord, mongoid" = tag_icon("cogs fa-2x", "Orm Agnostic")
Copy link

Copilot AI Mar 29, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The admin landing page tooltip lists supported ORMs, but it omits ohm and dynamoid, which are still supported by the admin generator. Update the title text to include all supported adapters (or make it generic) to avoid misleading users.

Suggested change
div class="btn btn-primary" title="Adapters for sequel, activerecord, minirecord, mongoid" = tag_icon("cogs fa-2x", "Orm Agnostic")
div class="btn btn-primary" title="Adapters for sequel, activerecord, minirecord, mongoid, ohm, dynamoid" = tag_icon("cogs fa-2x", "Orm Agnostic")

Copilot uses AI. Check for mistakes.
div class="btn btn-success" title="User Authentication Support, User Authorization Management" = tag_icon("group fa-2x", "Authentication")
div class="btn btn-info" title="Erb, Haml, Slim Rendering Support" = tag_icon("tasks fa-2x", "Template Agnostic")
div class="btn btn-warning" title="English, German, Russian, Danish, French, Brazilian and Italian localizations" = tag_icon("flag fa-2x", "Multi Language")
Expand Down
35 changes: 0 additions & 35 deletions padrino-admin/test/generators/test_account_model_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,6 @@
end
end

describe 'datamapper' do
before do
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=datamapper') }
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
@model = "#{@apptmp}/sample_project/models/account.rb"
end

it 'should include the datamapper resource' do
assert_match_in_file(/include DataMapper::Resource/m, @model)
end
end

describe 'mongoid' do
before do
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=mongoid') }
Expand All @@ -58,18 +46,6 @@
end
end

describe 'mongomapper' do
before do
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=mongomapper') }
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
@model = "#{@apptmp}/sample_project/models/account.rb"
end

it 'should include the mongomapper document' do
assert_match_in_file(/include MongoMapper::Document/m, @model)
end
end

describe 'ohm' do
before do
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=ohm') }
Expand All @@ -94,15 +70,4 @@
end
end

describe 'couchrest' do
before do
capture_io { generate(:project, 'sample_project', '-e=slim', "--root=#{@apptmp}", '-d=couchrest') }
capture_io { generate(:admin_app, "--root=#{@apptmp}/sample_project") }
@model = "#{@apptmp}/sample_project/models/account.rb"
end

it 'should be a couchrest model instance' do
assert_match_in_file(/class Account < CouchRest::Model::Base/m, @model)
end
end
end
Loading
Loading