├── lib
├── tasks
│ └── .gitkeep
├── generators
│ └── rails_admin
│ │ ├── templates
│ │ ├── rails_admin.js
│ │ ├── rails_admin.vite.js
│ │ ├── rails_admin.webpacker.js
│ │ └── rails_admin.scss.erb
│ │ └── utils.rb
└── rails_admin
│ ├── extensions
│ ├── controller_extension.rb
│ ├── pundit.rb
│ ├── paper_trail.rb
│ ├── cancancan.rb
│ └── url_for_extension.rb
│ ├── config
│ ├── sections
│ │ ├── modal.rb
│ │ ├── show.rb
│ │ ├── nested.rb
│ │ ├── update.rb
│ │ ├── export.rb
│ │ ├── create.rb
│ │ └── edit.rb
│ ├── fields
│ │ ├── types
│ │ │ ├── citext.rb
│ │ │ ├── inet.rb
│ │ │ ├── uuid.rb
│ │ │ ├── timestamp.rb
│ │ │ ├── has_many_association.rb
│ │ │ ├── has_and_belongs_to_many_association.rb
│ │ │ ├── integer.rb
│ │ │ ├── decimal.rb
│ │ │ ├── float.rb
│ │ │ ├── numeric.rb
│ │ │ ├── text.rb
│ │ │ ├── hidden.rb
│ │ │ ├── string_like.rb
│ │ │ └── serialized.rb
│ │ ├── factories
│ │ │ ├── action_text.rb
│ │ │ ├── password.rb
│ │ │ └── enum.rb
│ │ └── types.rb
│ ├── has_description.rb
│ ├── groupable.rb
│ ├── hideable.rb
│ ├── proxyable.rb
│ ├── actions
│ │ ├── show.rb
│ │ └── show_in_app.rb
│ └── has_groups.rb
│ ├── adapters
│ ├── active_record
│ │ └── object_extension.rb
│ └── mongoid
│ │ ├── bson.rb
│ │ └── object_extension.rb
│ └── support
│ ├── composite_keys_serializer.rb
│ ├── es_module_processor.rb
│ └── hash_helper.rb
├── spec
├── fixtures
│ ├── test.txt
│ ├── test.gif
│ ├── test.jpg
│ └── test.png
├── dummy_app
│ ├── lib
│ │ ├── tasks
│ │ │ └── .gitkeep
│ │ ├── assets
│ │ │ └── .gitkeep
│ │ └── does_not_load_autoload_paths_not_in_eager_load.rb
│ ├── public
│ │ ├── favicon.ico
│ │ ├── system
│ │ │ ├── dragonfly
│ │ │ │ └── development
│ │ │ │ │ └── 2011
│ │ │ │ │ └── 11
│ │ │ │ │ ├── 24
│ │ │ │ │ ├── 10_36_27_888_Pensive_Parakeet.jpg.meta
│ │ │ │ │ └── 10_36_27_888_Pensive_Parakeet.jpg
│ │ │ │ │ └── 30
│ │ │ │ │ ├── 08_54_39_906_Costa_Rican_Frog.jpg.meta
│ │ │ │ │ └── 08_54_39_906_Costa_Rican_Frog.jpg
│ │ │ └── paperclip_assets
│ │ │ │ ├── 1
│ │ │ │ ├── thumb
│ │ │ │ │ └── Boston City Flow.jpg
│ │ │ │ └── original
│ │ │ │ │ └── Boston City Flow.jpg
│ │ │ │ ├── 3
│ │ │ │ ├── thumb
│ │ │ │ │ └── Costa Rican Frog.jpg
│ │ │ │ └── original
│ │ │ │ │ └── Costa Rican Frog.jpg
│ │ │ │ └── 6
│ │ │ │ ├── thumb
│ │ │ │ └── liste-electorale.pdf
│ │ │ │ └── original
│ │ │ │ └── liste-electorale.pdf
│ │ ├── uploads
│ │ │ └── field_test
│ │ │ │ └── carrierwave_asset
│ │ │ │ ├── 3
│ │ │ │ ├── Boston_City_Flow.jpg
│ │ │ │ └── thumb_Boston_City_Flow.jpg
│ │ │ │ ├── 4
│ │ │ │ ├── Costa_Rican_Frog.jpg
│ │ │ │ └── thumb_Costa_Rican_Frog.jpg
│ │ │ │ └── 6
│ │ │ │ ├── Pensive_Parakeet.jpg
│ │ │ │ └── thumb_Pensive_Parakeet.jpg
│ │ ├── robots.txt
│ │ ├── 500.html
│ │ ├── 422.html
│ │ └── 404.html
│ ├── app
│ │ ├── assets
│ │ │ ├── builds
│ │ │ │ └── .keep
│ │ │ ├── stylesheets
│ │ │ │ ├── rails_admin
│ │ │ │ │ └── custom
│ │ │ │ │ │ └── theming.scss
│ │ │ │ ├── rails_admin.scss
│ │ │ │ └── application.css
│ │ │ ├── images
│ │ │ │ └── rails.png
│ │ │ ├── javascripts
│ │ │ │ ├── rails-ujs.esm.js.erb
│ │ │ │ ├── rails_admin
│ │ │ │ │ └── custom
│ │ │ │ │ │ └── ui.js
│ │ │ │ └── application.js
│ │ │ └── config
│ │ │ │ └── manifest.js
│ │ ├── mailers
│ │ │ └── .gitkeep
│ │ ├── active_record
│ │ │ ├── .gitkeep
│ │ │ ├── hardball.rb
│ │ │ ├── without_table.rb
│ │ │ ├── user
│ │ │ │ └── confirmed.rb
│ │ │ ├── paper_trail_test_subclass.rb
│ │ │ ├── cms.rb
│ │ │ ├── abstract.rb
│ │ │ ├── paper_trail_test.rb
│ │ │ ├── trail.rb
│ │ │ ├── concerns
│ │ │ │ └── taggable.rb
│ │ │ ├── read_only_comment.rb
│ │ │ ├── category.rb
│ │ │ ├── restricted_team.rb
│ │ │ ├── another_field_test.rb
│ │ │ ├── comment.rb
│ │ │ ├── comment
│ │ │ │ └── confirmed.rb
│ │ │ ├── paper_trail_test
│ │ │ │ └── subclass_in_namespace.rb
│ │ │ ├── deeply_nested_field_test.rb
│ │ │ ├── image.rb
│ │ │ ├── two_level
│ │ │ │ ├── namespaced.rb
│ │ │ │ └── namespaced
│ │ │ │ │ └── polymorphic_association_test.rb
│ │ │ ├── managed_team.rb
│ │ │ ├── cms
│ │ │ │ └── basic_page.rb
│ │ │ ├── paper_trail_test_with_custom_association.rb
│ │ │ ├── nested_favorite_player.rb
│ │ │ ├── shrine_uploader.rb
│ │ │ ├── ball.rb
│ │ │ ├── nested_fan.rb
│ │ │ ├── managing_user.rb
│ │ │ ├── division.rb
│ │ │ ├── fan.rb
│ │ │ ├── league.rb
│ │ │ ├── draft.rb
│ │ │ ├── nested_field_test.rb
│ │ │ ├── shrine_versioning_uploader.rb
│ │ │ ├── favorite_player.rb
│ │ │ ├── fanship.rb
│ │ │ ├── user.rb
│ │ │ └── player.rb
│ │ ├── javascript
│ │ │ ├── rails_admin.scss
│ │ │ ├── application.js
│ │ │ └── rails_admin.js
│ │ ├── mongoid
│ │ │ ├── hardball.rb
│ │ │ ├── user
│ │ │ │ └── confirmed.rb
│ │ │ ├── cms.rb
│ │ │ ├── concerns
│ │ │ │ └── taggable.rb
│ │ │ ├── read_only_comment.rb
│ │ │ ├── embed.rb
│ │ │ ├── category.rb
│ │ │ ├── restricted_team.rb
│ │ │ ├── comment
│ │ │ │ └── confirmed.rb
│ │ │ ├── another_field_test.rb
│ │ │ ├── managed_team.rb
│ │ │ ├── comment.rb
│ │ │ ├── fan.rb
│ │ │ ├── shrine_uploader.rb
│ │ │ ├── image.rb
│ │ │ ├── deeply_nested_field_test.rb
│ │ │ ├── cms
│ │ │ │ └── basic_page.rb
│ │ │ ├── two_level
│ │ │ │ └── namespaced
│ │ │ │ │ └── polymorphic_association_test.rb
│ │ │ ├── league.rb
│ │ │ ├── division.rb
│ │ │ ├── ball.rb
│ │ │ ├── managing_user.rb
│ │ │ ├── shrine_versioning_uploader.rb
│ │ │ ├── nested_field_test.rb
│ │ │ └── draft.rb
│ │ ├── frontend
│ │ │ ├── entrypoints
│ │ │ │ ├── application.js
│ │ │ │ └── rails_admin.js
│ │ │ └── stylesheets
│ │ │ │ └── rails_admin.scss
│ │ ├── eager_loaded
│ │ │ └── basketball.rb
│ │ ├── views
│ │ │ ├── players
│ │ │ │ └── show.html.erb
│ │ │ └── layouts
│ │ │ │ └── application.html.erb
│ │ ├── controllers
│ │ │ ├── application_controller.rb
│ │ │ └── players_controller.rb
│ │ ├── jobs
│ │ │ ├── null_job.rb
│ │ │ └── application_job.rb
│ │ └── locales
│ │ │ └── models.en.yml
│ ├── vendor
│ │ └── javascript
│ │ │ └── .keep
│ ├── .browserslistrc
│ ├── bin
│ │ ├── docker-entrypoint
│ │ ├── rake
│ │ ├── importmap
│ │ ├── rails
│ │ ├── dev
│ │ ├── webpack
│ │ ├── webpack-dev-server
│ │ ├── vite
│ │ └── update
│ ├── Procfile.dev
│ ├── config
│ │ ├── storage.yml
│ │ ├── locales
│ │ │ └── en.yml
│ │ ├── webpack
│ │ │ ├── environment.js
│ │ │ ├── test.js
│ │ │ ├── development.js
│ │ │ └── production.js
│ │ ├── puma.rb
│ │ ├── dockerfile.yml
│ │ ├── initializers
│ │ │ ├── session_store.rb
│ │ │ ├── mime_types.rb
│ │ │ ├── shrine.rb
│ │ │ ├── application_controller_renderer.rb
│ │ │ ├── filter_parameter_logging.rb
│ │ │ ├── mongoid.rb
│ │ │ ├── cookies_serializer.rb
│ │ │ ├── backtrace_silencers.rb
│ │ │ ├── cors.rb
│ │ │ ├── wrap_parameters.rb
│ │ │ ├── dragonfly.rb
│ │ │ ├── session_patch.rb
│ │ │ ├── rails_admin.rb
│ │ │ ├── inflections.rb
│ │ │ ├── secret_token.rb
│ │ │ └── assets.rb
│ │ ├── environment.rb
│ │ ├── routes.rb
│ │ ├── vite.json
│ │ ├── boot.rb
│ │ ├── mongoid5.yml
│ │ ├── mongoid6.yml
│ │ ├── importmap.rb
│ │ └── database.yml
│ ├── vite.config.ts
│ ├── config.ru
│ ├── db
│ │ └── migrate
│ │ │ ├── 20111115041025_add_type_to_balls.rb
│ │ │ ├── 20211011235734_add_bool_field_open.rb
│ │ │ ├── 20120117151733_add_custom_field_to_teams.rb
│ │ │ ├── 20160728152942_add_main_sponsor_to_teams.rb
│ │ │ ├── 20120118122004_add_categories.rb
│ │ │ ├── 20160728153058_add_formation_to_players.rb
│ │ │ ├── 20111130075338_add_dragonfly_asset_name_to_field_tests.rb
│ │ │ ├── 20110901142530_rename_league_id_foreign_key_on_divisions.rb
│ │ │ ├── 20111215083258_create_foo_bars.rb
│ │ │ ├── 20151027181550_change_field_test_id_to_nested_field_tests.rb
│ │ │ ├── 20180707101855_add_carrierwave_assets_to_field_tests.rb
│ │ │ ├── 20240921171953_add_non_nullable_boolean_field.rb
│ │ │ ├── 00000000000013_add_roles_to_user.rb
│ │ │ ├── 00000000000014_add_color_to_team_migration.rb
│ │ │ ├── 20140826093220_create_paper_trail_tests.rb
│ │ │ ├── 20171229220713_add_enum_fields_to_field_tests.rb
│ │ │ ├── 20110329183136_remove_league_id_from_teams.rb
│ │ │ ├── 20110607152842_add_format_to_field_test.rb
│ │ │ ├── 20181029101829_add_shrine_data_to_field_tests.rb
│ │ │ ├── 00000000000010_add_revenue_to_team_migration.rb
│ │ │ ├── 00000000000011_add_suspended_to_player_migration.rb
│ │ │ ├── 20110714095433_create_balls.rb
│ │ │ ├── 20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb
│ │ │ ├── 20111123092549_create_nested_field_tests.rb
│ │ │ ├── 00000000000009_create_fans_teams_migration.rb
│ │ │ ├── 20120720075608_create_another_field_tests.rb
│ │ │ ├── 20110123042530_rename_histories_to_rails_admin_histories.rb
│ │ │ ├── 20110901154834_change_length_for_rails_admin_histories.rb
│ │ │ ├── 20140412075608_create_deeply_nested_field_tests.rb
│ │ │ ├── 00000000000008_create_fans_migration.rb
│ │ │ ├── 00000000000003_create_leagues_migration.rb
│ │ │ ├── 20120928075608_create_images.rb
│ │ │ ├── 20210811121027_create_two_level_namespaced_polymorphic_association_tests.rb
│ │ │ ├── 20110328193014_create_cms_basic_pages.rb
│ │ │ ├── 20111108143642_add_dragonfly_and_carrierwave_to_field_tests.rb
│ │ │ ├── 00000000000001_create_divisions_migration.rb
│ │ │ ├── 20110103205808_create_comments.rb
│ │ │ ├── 20101223222233_create_rel_tests.rb
│ │ │ ├── 20120319041705_drop_rel_tests.rb
│ │ │ ├── 20150815102450_add_refile_to_field_tests.rb
│ │ │ ├── 20140826093552_create_versions.rb
│ │ │ ├── 20210812115908_create_custom_versions.rb
│ │ │ ├── 00000000000007_create_histories_table.rb
│ │ │ ├── 20220416102741_create_composite_key_tables.rb
│ │ │ ├── 00000000000002_create_drafts_migration.rb
│ │ │ ├── 20190531065324_create_action_text_tables.action_text.rb
│ │ │ ├── 20201127111952_update_active_storage_tables.rb
│ │ │ ├── 20110901131551_change_division_primary_key.rb
│ │ │ ├── 00000000000012_add_avatar_columns_to_user.rb
│ │ │ ├── 00000000000004_create_players_migration.rb
│ │ │ ├── 20110224184303_create_field_tests.rb
│ │ │ ├── 20110901150912_set_primary_key_not_null_for_divisions.rb
│ │ │ └── 00000000000005_create_teams_migration.rb
│ ├── doc
│ │ └── README_FOR_APP
│ ├── postcss.config.js
│ ├── Rakefile
│ ├── webpack.config.js
│ ├── fly.toml
│ ├── .gitignore
│ ├── package.json
│ └── .dockerignore
├── support
│ ├── fixtures.rb
│ ├── cuprite_logger.rb
│ └── fakeio.rb
├── rails_admin
│ ├── config
│ │ ├── fields
│ │ │ └── types
│ │ │ │ ├── float_spec.rb
│ │ │ │ ├── decimal_spec.rb
│ │ │ │ ├── inet_spec.rb
│ │ │ │ ├── integer_spec.rb
│ │ │ │ ├── serialized_spec.rb
│ │ │ │ ├── has_many_association_spec.rb
│ │ │ │ ├── has_one_association_spec.rb
│ │ │ │ ├── belongs_to_association_spec.rb
│ │ │ │ ├── text_spec.rb
│ │ │ │ ├── citext_spec.rb
│ │ │ │ ├── color_spec.rb
│ │ │ │ ├── froala_spec.rb
│ │ │ │ ├── has_and_belongs_to_many_association_spec.rb
│ │ │ │ ├── hidden_spec.rb
│ │ │ │ ├── ck_editor_spec.rb
│ │ │ │ ├── wysihtml5_spec.rb
│ │ │ │ ├── simple_mde_spec.rb
│ │ │ │ ├── code_mirror_spec.rb
│ │ │ │ ├── action_text_spec.rb
│ │ │ │ ├── numeric_spec.rb
│ │ │ │ ├── paperclip_spec.rb
│ │ │ │ ├── timestamp_spec.rb
│ │ │ │ ├── bson_object_id_spec.rb
│ │ │ │ ├── carrierwave_spec.rb
│ │ │ │ ├── uuid_spec.rb
│ │ │ │ └── string_spec.rb
│ │ ├── has_description_spec.rb
│ │ ├── fields_spec.rb
│ │ └── sections
│ │ │ └── list_spec.rb
│ ├── adapters
│ │ └── active_record
│ │ │ └── object_extension_spec.rb
│ ├── active_record_extension_spec.rb
│ └── extentions
│ │ ├── paper_trail
│ │ └── version_proxy_spec.rb
│ │ └── cancancan
│ │ └── authorization_adapter_spec.rb
├── integration
│ ├── fields
│ │ ├── color_spec.rb
│ │ ├── paperclip_spec.rb
│ │ ├── ck_editor_spec.rb
│ │ ├── code_mirror_spec.rb
│ │ ├── simple_mde_spec.rb
│ │ ├── shrine_spec.rb
│ │ ├── carrierwave_spec.rb
│ │ ├── floara_spec.rb
│ │ └── wysihtml5_spec.rb
│ ├── actions
│ │ └── show_in_app_spec.rb
│ └── authentication
│ │ └── devise_spec.rb
└── orm
│ └── mongoid.rb
├── Procfile.teatro
├── src
└── rails_admin
│ ├── styles
│ ├── base
│ │ ├── mixins.scss
│ │ ├── variables.scss
│ │ └── README.txt
│ ├── widgets.scss
│ └── base.scss
│ ├── jquery.js
│ ├── i18n.js
│ ├── sidescroll.js
│ └── abstract-select.js
├── .yardopts
├── app
├── assets
│ ├── javascripts
│ │ └── rails_admin
│ │ │ └── custom
│ │ │ └── ui.js
│ └── stylesheets
│ │ └── rails_admin
│ │ ├── custom
│ │ ├── theming.scss
│ │ ├── mixins.scss
│ │ └── variables.scss
│ │ └── application.scss.erb
└── views
│ ├── kaminari
│ └── ra-twitter-bootstrap
│ │ ├── _gap.html.erb
│ │ ├── without_count
│ │ ├── _paginator.html.erb
│ │ ├── _next_page.html.erb
│ │ └── _prev_page.html.erb
│ │ ├── _page.html.erb
│ │ ├── _next_page.html.erb
│ │ ├── _prev_page.html.erb
│ │ └── _paginator.html.erb
│ ├── rails_admin
│ └── main
│ │ ├── _form_field.html.erb
│ │ ├── _form_text.html.erb
│ │ ├── _form_colorpicker.html.erb
│ │ ├── new.html.erb
│ │ ├── edit.html.erb
│ │ ├── _form_action_text.html.erb
│ │ ├── _form_froala.html.erb
│ │ ├── _form_simple_mde.html.erb
│ │ ├── _form_wysihtml5.html.erb
│ │ ├── _form_code_mirror.html.erb
│ │ ├── _form_ck_editor.html.erb
│ │ ├── _form_datetime.html.erb
│ │ ├── _form_file_upload.html.erb
│ │ ├── bulk_delete.html.erb
│ │ └── _form_boolean.html.erb
│ └── layouts
│ └── rails_admin
│ ├── _sidebar_navigation.html.erb
│ ├── modal.js.erb
│ ├── _navigation.html.erb
│ └── content.html.erb
├── .rspec
├── vendor
└── assets
│ ├── stylesheets
│ └── rails_admin
│ │ └── bootstrap
│ │ ├── helpers
│ │ ├── _clearfix.scss
│ │ ├── _text-truncation.scss
│ │ ├── _vr.scss
│ │ ├── _visually-hidden.scss
│ │ ├── _stretched-link.scss
│ │ ├── _stacks.scss
│ │ ├── _colored-links.scss
│ │ ├── _ratio.scss
│ │ └── _position.scss
│ │ ├── mixins
│ │ ├── _clearfix.scss
│ │ ├── _lists.scss
│ │ ├── _color-scheme.scss
│ │ ├── _text-truncate.scss
│ │ ├── _resize.scss
│ │ ├── _container.scss
│ │ ├── _alert.scss
│ │ ├── _backdrop.scss
│ │ ├── _image.scss
│ │ ├── _box-shadow.scss
│ │ ├── _reset-text.scss
│ │ ├── _list-group.scss
│ │ ├── _deprecate.scss
│ │ ├── _transition.scss
│ │ └── _pagination.scss
│ │ ├── forms
│ │ ├── _form-text.scss
│ │ └── _validation.scss
│ │ ├── _forms.scss
│ │ ├── _helpers.scss
│ │ ├── _transitions.scss
│ │ ├── _grid.scss
│ │ └── _badge.scss
│ ├── fonts
│ └── rails_admin
│ │ ├── fa-solid-900.ttf
│ │ └── fa-solid-900.woff2
│ └── javascripts
│ └── rails_admin
│ └── jquery-ui
│ ├── version.js
│ └── ie.js
├── .prettierignore
├── config
├── initializers
│ ├── mongoid_extensions.rb
│ └── active_record_extensions.rb
└── routes.rb
├── .teatro.yml
├── .github
├── ISSUE_TEMPLATE
│ ├── feature_request.md
│ └── bug_report.md
└── workflows
│ └── code-ql.yml
├── .gitignore
└── package.json
/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/fixtures/test.txt:
--------------------------------------------------------------------------------
1 | test
--------------------------------------------------------------------------------
/spec/dummy_app/lib/tasks/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/public/favicon.ico:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/builds/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mailers/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/lib/assets/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/vendor/javascript/.keep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/spec/dummy_app/.browserslistrc:
--------------------------------------------------------------------------------
1 | defaults
2 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/.gitkeep:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/Procfile.teatro:
--------------------------------------------------------------------------------
1 | web: cd spec/dummy_app && bundle exec rails server
2 |
--------------------------------------------------------------------------------
/src/rails_admin/styles/base/mixins.scss:
--------------------------------------------------------------------------------
1 | /* RailsAdmin SASS mixins */
2 |
--------------------------------------------------------------------------------
/spec/dummy_app/bin/docker-entrypoint:
--------------------------------------------------------------------------------
1 | #!/bin/bash -e
2 |
3 | exec "${@}"
4 |
--------------------------------------------------------------------------------
/.yardopts:
--------------------------------------------------------------------------------
1 | --no-private
2 | --protected
3 | --markup markdown
4 | -
5 | LICENSE.md
6 |
--------------------------------------------------------------------------------
/lib/generators/rails_admin/templates/rails_admin.js:
--------------------------------------------------------------------------------
1 | import "rails_admin/src/rails_admin/base";
2 |
--------------------------------------------------------------------------------
/src/rails_admin/jquery.js:
--------------------------------------------------------------------------------
1 | import jQuery from "jquery";
2 |
3 | window.$ = window.jQuery = jQuery;
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/javascript/rails_admin.scss:
--------------------------------------------------------------------------------
1 | @import "rails_admin/src/rails_admin/styles/base.scss";
2 |
--------------------------------------------------------------------------------
/spec/fixtures/test.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/fixtures/test.gif
--------------------------------------------------------------------------------
/spec/fixtures/test.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/fixtures/test.jpg
--------------------------------------------------------------------------------
/spec/fixtures/test.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/fixtures/test.png
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/hardball.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Hardball < Ball
4 | end
5 |
--------------------------------------------------------------------------------
/app/assets/javascripts/rails_admin/custom/ui.js:
--------------------------------------------------------------------------------
1 | // override this file in your application to add custom behaviour
2 |
--------------------------------------------------------------------------------
/spec/dummy_app/Procfile.dev:
--------------------------------------------------------------------------------
1 | web: bin/rails server -p 3000
2 | css: yarn build:css --watch
3 | vite: bin/vite dev
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/hardball.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Hardball < Ball
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/frontend/entrypoints/application.js:
--------------------------------------------------------------------------------
1 | import "@rails/ujs";
2 | import "@hotwired/turbo-rails";
3 |
--------------------------------------------------------------------------------
/.rspec:
--------------------------------------------------------------------------------
1 | --color
2 | --order=random
3 | --profile
4 | --exclude-pattern 'dummy_app/node_modules/rails_admin/**/*_spec.rb'
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/stylesheets/rails_admin/custom/theming.scss:
--------------------------------------------------------------------------------
1 | .navbar-brand small {
2 | opacity: 0.99;
3 | }
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/eager_loaded/basketball.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Basketball < Ball
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/storage.yml:
--------------------------------------------------------------------------------
1 | local:
2 | service: Disk
3 | root: <%= Rails.root.join('public', 'system') %>
4 |
--------------------------------------------------------------------------------
/src/rails_admin/styles/base/variables.scss:
--------------------------------------------------------------------------------
1 | /* RailsAdmin SASS variables */
2 |
3 | $font-size-base: 0.85rem !default;
4 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_clearfix.scss:
--------------------------------------------------------------------------------
1 | .clearfix {
2 | @include clearfix();
3 | }
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/locales/en.yml:
--------------------------------------------------------------------------------
1 | en:
2 | admin:
3 | help:
4 | team:
5 | name: "Team Name Help Text."
6 |
--------------------------------------------------------------------------------
/spec/dummy_app/bin/rake:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require_relative '../config/boot'
3 | require 'rake'
4 | Rake.application.run
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/bin/importmap:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 |
3 | require_relative "../config/application"
4 | require "importmap/commands"
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/without_table.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class WithoutTable < ActiveRecord::Base
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/javascript/application.js:
--------------------------------------------------------------------------------
1 | import Rails from "@rails/ujs";
2 | import "@hotwired/turbo-rails";
3 |
4 | Rails.start();
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/webpack/environment.js:
--------------------------------------------------------------------------------
1 | const { environment } = require("@rails/webpacker");
2 |
3 | module.exports = environment;
4 |
--------------------------------------------------------------------------------
/lib/generators/rails_admin/templates/rails_admin.vite.js:
--------------------------------------------------------------------------------
1 | import "~/stylesheets/rails_admin.scss";
2 | import "rails_admin/src/rails_admin/base";
3 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/images/rails.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/app/assets/images/rails.png
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/user/confirmed.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class User
4 | class Confirmed < User
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/user/confirmed.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class User
4 | class Confirmed < User
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/cms.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Cms
4 | def self.table_name_prefix
5 | 'cms_'
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/puma.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | threads 0, ENV.fetch('RAILS_MAX_THREADS', 3)
4 | port ENV.fetch('PORT', 3000)
5 |
--------------------------------------------------------------------------------
/lib/generators/rails_admin/templates/rails_admin.webpacker.js:
--------------------------------------------------------------------------------
1 | import "rails_admin/src/rails_admin/base";
2 | import "../stylesheets/rails_admin.scss";
3 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/paper_trail_test_subclass.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class PaperTrailTestSubclass < PaperTrailTest
4 | end
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/javascripts/rails-ujs.esm.js.erb:
--------------------------------------------------------------------------------
1 | <%= depend_on_asset('rails-ujs').to_s.gsub(/context = this/, 'context = (this || globalThis)') %>
--------------------------------------------------------------------------------
/vendor/assets/fonts/rails_admin/fa-solid-900.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/vendor/assets/fonts/rails_admin/fa-solid-900.ttf
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/cms.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Cms
4 | def self.table_name_prefix
5 | 'cms_'
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/dockerfile.yml:
--------------------------------------------------------------------------------
1 | # generated by dockerfile-rails
2 | ---
3 | options:
4 | label:
5 | fly_launch_runtime: rails
6 | sentry: false
7 |
--------------------------------------------------------------------------------
/vendor/assets/fonts/rails_admin/fa-solid-900.woff2:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/vendor/assets/fonts/rails_admin/fa-solid-900.woff2
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/abstract.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Abstract < ActiveRecord::Base
4 | self.abstract_class = true
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/paper_trail_test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class PaperTrailTest < ActiveRecord::Base
4 | has_paper_trail
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/trail.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Trail < PaperTrail::Version
4 | self.table_name = :custom_versions
5 | end
6 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/stylesheets/rails_admin.scss:
--------------------------------------------------------------------------------
1 | $fa-font-path: ".";
2 | @import "rails_admin/src/rails_admin/styles/base.scss";
3 | @import "trix/dist/trix";
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/concerns/taggable.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Taggable
4 | extend ActiveSupport::Concern
5 | # dummy
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/concerns/taggable.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Taggable
4 | extend ActiveSupport::Concern
5 | # dummy
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/config/manifest.js:
--------------------------------------------------------------------------------
1 | //= link_tree ../images
2 | //= link_tree ../../../../../src .js
3 | //= link application.js
4 | //= link application.css
5 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/frontend/stylesheets/rails_admin.scss:
--------------------------------------------------------------------------------
1 | $fa-font-path: "@fortawesome/fontawesome-free/webfonts";
2 | @import "rails_admin/src/rails_admin/styles/base";
3 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/read_only_comment.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ReadOnlyComment < Comment
4 | def readonly?
5 | true
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/views/players/show.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 | <%= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({class: 'form-control', value: field.form_value}) %>
4 |
5 |
6 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/cms/basic_page.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module Cms
4 | class BasicPage < ActiveRecord::Base
5 | self.table_name = :cms_basic_pages
6 |
7 | validates :title, :content, presence: true
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_text-truncate.scss:
--------------------------------------------------------------------------------
1 | // Text truncate
2 | // Requires inline-block or block for proper styling
3 |
4 | @mixin text-truncate() {
5 | overflow: hidden;
6 | text-overflow: ellipsis;
7 | white-space: nowrap;
8 | }
9 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20160728152942_add_main_sponsor_to_teams.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddMainSponsorToTeams < ActiveRecord::Migration[5.0]
4 | def change
5 | add_column :teams, :main_sponsor, :integer, default: 0, null: false
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/paper_trail_test_with_custom_association.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class PaperTrailTestWithCustomAssociation < ActiveRecord::Base
4 | self.table_name = :paper_trail_tests
5 | has_paper_trail versions: {class_name: 'Trail'}
6 | end
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/comment.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Comment
4 | include Mongoid::Document
5 | field :content, type: String
6 | include Mongoid::Timestamps
7 | include Taggable
8 |
9 | belongs_to :commentable, polymorphic: true
10 | end
11 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/fan.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Fan
4 | include Mongoid::Document
5 | include Mongoid::Timestamps
6 |
7 | field :name, type: String
8 |
9 | has_and_belongs_to_many :teams
10 |
11 | validates_presence_of(:name)
12 | end
13 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20120118122004_add_categories.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddCategories < ActiveRecord::Migration[5.0]
4 | def change
5 | create_table :categories do |t|
6 | t.integer :parent_category_id
7 | end
8 | end
9 | end
10 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20160728153058_add_formation_to_players.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddFormationToPlayers < ActiveRecord::Migration[5.0]
4 | def change
5 | add_column :players, :formation, :string, default: 'substitute', null: false
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_resize.scss:
--------------------------------------------------------------------------------
1 | // Resize anything
2 |
3 | @mixin resizable($direction) {
4 | overflow: auto; // Per CSS3 UI, `resize` only applies when `overflow` isn't `visible`
5 | resize: $direction; // Options: horizontal, vertical, both
6 | }
7 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/shrine_uploader.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ShrineUploader < Shrine
4 | plugin :mongoid
5 |
6 | plugin :cached_attachment_data
7 | plugin :determine_mime_type
8 | plugin :pretty_location
9 | plugin :remove_attachment
10 | end
11 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/application_controller_renderer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # ApplicationController.renderer.defaults.merge!(
6 | # http_host: 'example.org',
7 | # https: false
8 | # )
9 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20111130075338_add_dragonfly_asset_name_to_field_tests.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddDragonflyAssetNameToFieldTests < ActiveRecord::Migration[5.0]
4 | def change
5 | add_column :field_tests, :dragonfly_asset_name, :string
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/rails_admin/main/new.html.erb:
--------------------------------------------------------------------------------
1 | <%= rails_admin_form_for @object, url: new_path(model_name: @abstract_model.to_param), as: @abstract_model.param_key, html: { multipart: true, class: "main", data: { title: @page_name } } do |form| %>
2 | <%= form.generate action: :create %>
3 | <% end %>
4 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20110901142530_rename_league_id_foreign_key_on_divisions.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class RenameLeagueIdForeignKeyOnDivisions < ActiveRecord::Migration[5.0]
4 | def change
5 | rename_column :divisions, :league_id, :custom_league_id
6 | end
7 | end
8 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/has_many_association_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::HasManyAssociation do
6 | it_behaves_like 'a generic field type', :integer_field, :has_many_association
7 | end
8 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/has_one_association_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::HasOneAssociation do
6 | it_behaves_like 'a generic field type', :integer_field, :has_one_association
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/kaminari/ra-twitter-bootstrap/without_count/_paginator.html.erb:
--------------------------------------------------------------------------------
1 | <%= paginator.render do %>
2 |
2 |
3 |
4 | <%= form.text_field field.method_name, field.html_attributes.reverse_merge({autocomplete: 'off', class: 'form-control', data: {datetimepicker: true, options: field.datepicker_options.to_json}, value: field.form_value}) %>
5 | <%= form.label(field.method_name, class: 'input-group-text') do %>
6 |
7 | <% end %>
8 |
9 |
10 |
11 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20220416102741_create_composite_key_tables.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateCompositeKeyTables < ActiveRecord::Migration[6.0]
4 | def change
5 | add_column :fans_teams, :since, :date
6 |
7 | create_table :favorite_players, primary_key: %i[fan_id team_id player_id] do |t|
8 | t.integer :fan_id, null: false
9 | t.integer :team_id, null: false
10 | t.integer :player_id, null: false
11 | t.string :reason
12 |
13 | t.timestamps
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_box-shadow.scss:
--------------------------------------------------------------------------------
1 | @mixin box-shadow($shadow...) {
2 | @if $enable-shadows {
3 | $result: ();
4 |
5 | @each $value in $shadow {
6 | @if $value != null {
7 | $result: append($result, $value, "comma");
8 | }
9 | @if $value == none and length($shadow) > 1 {
10 | @warn "The keyword 'none' must be used as a single argument.";
11 | }
12 | }
13 |
14 | @if (length($result) > 0) {
15 | box-shadow: $result;
16 | }
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/collection_association'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class HasAndBelongsToManyAssociation < RailsAdmin::Config::Fields::CollectionAssociation
10 | # Register field type for the type loader
11 | RailsAdmin::Config::Fields::Types.register(self)
12 | end
13 | end
14 | end
15 | end
16 | end
17 |
--------------------------------------------------------------------------------
/src/rails_admin/i18n.js:
--------------------------------------------------------------------------------
1 | var I18n = {
2 | locale: null,
3 | translations: null,
4 | init(locale, translations) {
5 | this.locale = locale;
6 | this.translations = translations;
7 | if (typeof this.translations === "string") {
8 | this.translations = JSON.parse(this.translations);
9 | }
10 | },
11 | t(key) {
12 | var humanize;
13 | humanize = key.charAt(0).toUpperCase() + key.replace(/_/g, " ").slice(1);
14 | return this.translations[key] || humanize;
15 | },
16 | };
17 |
18 | export { I18n as default };
19 |
--------------------------------------------------------------------------------
/src/rails_admin/styles/widgets.scss:
--------------------------------------------------------------------------------
1 | iframe.wysihtml5-sandbox {
2 | height: 250px !important;
3 | width: 99.7% !important;
4 | }
5 |
6 | iframe.wysihtml5-sandbox,
7 | .wysihtml5-editor {
8 | border: 1px solid #ccc !important;
9 | }
10 |
11 | .controls img.preview {
12 | max-height: 200px;
13 | max-width: 300px;
14 | }
15 |
16 | .controls.ui-sortable .sortables {
17 | cursor: move;
18 | }
19 |
20 | .form-group.hidden_type {
21 | display: none;
22 | }
23 |
24 | .links .list-inline .disabled span {
25 | color: $gray-600;
26 | }
27 |
--------------------------------------------------------------------------------
/spec/orm/mongoid.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/adapters/mongoid'
4 |
5 | Paperclip.logger = Logger.new(nil)
6 |
7 | class Tableless
8 | include Mongoid::Document
9 |
10 | class << self
11 | def column(name, sql_type = 'string', default = nil, _null = true)
12 | # ignore length
13 | sql_type = sql_type.to_s.sub(/\(.*\)/, '').to_sym
14 | field(name, type: {integer: Integer, string: String, text: String, date: Date, datetime: DateTime}[sql_type], default: default)
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/javascript/rails_admin.js:
--------------------------------------------------------------------------------
1 | import "rails_admin/src/rails_admin/base";
2 | import "flatpickr/dist/l10n/fr.js";
3 | import "trix";
4 | import "@rails/actiontext";
5 | import * as ActiveStorage from "@rails/activestorage";
6 | ActiveStorage.start();
7 |
8 | window.domReadyTriggered = [];
9 |
10 | document.addEventListener("rails_admin.dom_ready", function () {
11 | window.domReadyTriggered.push("plainjs/dot");
12 | });
13 |
14 | $(document).on("rails_admin.dom_ready", function () {
15 | window.domReadyTriggered.push("jquery/dot");
16 | });
17 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/feature_request.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Feature request
3 | about: Suggest an idea for this project
4 | title: ""
5 | labels: enhancement
6 | assignees: ""
7 | ---
8 |
9 | **Is your feature request related to a problem? Please describe.**
10 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
11 |
12 | **Describe proposed solution(s)**
13 | A clear and concise description of what you want to happen.
14 |
15 | **Additional context**
16 | Add any other context or screenshots about the feature request here.
17 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.gem
2 | *.log
3 | *.rbc
4 | *.swp
5 | .bundle
6 | .idea/
7 | .vscode/
8 | .rvmrc
9 | .sass-cache
10 | .yardoc
11 | /.emacs.desktop
12 | /gemfiles/*.lock
13 | /node_modules/*
14 | /rails_admin.gems
15 | /spec/generators/tmp
16 | /spec/lib/tmp
17 | /yarn.lock
18 | Gemfile.lock
19 | coverage/*
20 | db/*.sqlite3
21 | db/*.sqlite3-journal
22 | doc/*
23 | log/*.log
24 | pkg/*
25 | spec/dummy_app/db/*.sqlite3
26 | spec/dummy_app/db/*.sqlite3-journal
27 | spec/dummy_app/log/*.log
28 | spec/dummy_app/public/uploads
29 | spec/dummy_app/Gemfile*.lock
30 | tmp/**/*
31 | nbproject
32 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/importmap.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Pin npm packages by running ./bin/importmap
4 |
5 | pin 'application', preload: true
6 | pin '@hotwired/turbo-rails', to: 'https://ga.jspm.io/npm:@hotwired/turbo-rails@7.1.3/app/javascript/turbo/index.js'
7 | pin '@rails/ujs', to: 'https://ga.jspm.io/npm:@rails/ujs@6.0.5/lib/assets/compiled/rails-ujs.js'
8 | pin '@hotwired/turbo', to: 'https://ga.jspm.io/npm:@hotwired/turbo@7.1.0/dist/turbo.es2017-esm.js'
9 | pin '@rails/actioncable/src', to: 'https://ga.jspm.io/npm:@rails/actioncable@7.0.3/src/index.js'
10 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/00000000000002_create_drafts_migration.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateDraftsMigration < ActiveRecord::Migration[5.0]
4 | def self.up
5 | create_table :drafts do |t|
6 | t.timestamps null: false
7 | t.integer :player_id
8 | t.integer :team_id
9 | t.date :date
10 | t.integer :round
11 | t.integer :pick
12 | t.integer :overall
13 | t.string :college, limit: 100
14 | t.text :notes
15 | end
16 | end
17 |
18 | def self.down
19 | drop_table :drafts
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/rails_admin/custom/mixins.scss:
--------------------------------------------------------------------------------
1 | /*
2 | Customize Sass mixins from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use.
3 | Copy this file to your app/assets/rails_admin/custom/mixins.scss, leave this one untouched
4 | Don't require it in your application.rb
5 |
6 | Available mixins to use/override:
7 |
8 | https://github.com/twbs/bootstrap-sass/tree/master/assets/stylesheets/bootstrap/mixins
9 | https://github.com/railsadminteam/rails_admin/blob/master/src/rails_admin/styles/base/mixins.scss
10 | Plus the ones from your theme.
11 | */
12 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/integer.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/types/numeric'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class Integer < RailsAdmin::Config::Fields::Types::Numeric
10 | # Register field type for the type loader
11 | RailsAdmin::Config::Fields::Types.register(self)
12 |
13 | register_instance_option :sort_reverse? do
14 | serial?
15 | end
16 | end
17 | end
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20190531065324_create_action_text_tables.action_text.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class CreateActionTextTables < ActiveRecord::Migration[5.0]
4 | def change
5 | create_table :action_text_rich_texts do |t|
6 | t.string :name, null: false
7 | t.text :body, size: :long
8 | t.references :record, null: false, polymorphic: true, index: false
9 |
10 | t.timestamps
11 |
12 | t.index %i[record_type record_id name], name: 'index_action_text_rich_texts_uniqueness', unique: true
13 | end
14 | end
15 | end
16 |
--------------------------------------------------------------------------------
/lib/rails_admin/support/es_module_processor.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | module Support
5 | class ESModuleProcessor
6 | def self.instance
7 | @instance ||= new
8 | end
9 |
10 | def self.call(input)
11 | instance.call(input)
12 | end
13 |
14 | def initialize; end
15 |
16 | def call(input)
17 | return unless input[:name] == 'rails_admin/application'
18 |
19 | input[:data].gsub(/^((?:import|export) .+)$/) { "// #{Regexp.last_match(1)}" }
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/forms/_validation.scss:
--------------------------------------------------------------------------------
1 | // Form validation
2 | //
3 | // Provide feedback to users when form field values are valid or invalid. Works
4 | // primarily for client-side validation via scoped `:invalid` and `:valid`
5 | // pseudo-classes but also includes `.is-invalid` and `.is-valid` classes for
6 | // server-side validation.
7 |
8 | // scss-docs-start form-validation-states-loop
9 | @each $state, $data in $form-validation-states {
10 | @include form-validation-state($state, $data...);
11 | }
12 | // scss-docs-end form-validation-states-loop
13 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_ratio.scss:
--------------------------------------------------------------------------------
1 | // Credit: Nicolas Gallagher and SUIT CSS.
2 |
3 | .ratio {
4 | position: relative;
5 | width: 100%;
6 |
7 | &::before {
8 | display: block;
9 | padding-top: var(--#{$variable-prefix}aspect-ratio);
10 | content: "";
11 | }
12 |
13 | > * {
14 | position: absolute;
15 | top: 0;
16 | left: 0;
17 | width: 100%;
18 | height: 100%;
19 | }
20 | }
21 |
22 | @each $key, $ratio in $aspect-ratios {
23 | .ratio-#{$key} {
24 | --#{$variable-prefix}aspect-ratio: #{$ratio};
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/numeric_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::Numeric do
6 | it_behaves_like 'a generic field type', :integer_field, :integer
7 |
8 | subject do
9 | RailsAdmin.config('FieldTest').fields.detect do |f|
10 | f.name == :integer_field
11 | end.with(object: FieldTest.new)
12 | end
13 |
14 | describe '#view_helper' do
15 | it "uses the 'number' type input tag" do
16 | expect(subject.view_helper).to eq(:number_field)
17 | end
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20201127111952_update_active_storage_tables.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class UpdateActiveStorageTables < ActiveRecord::Migration[5.0]
4 | def change
5 | add_column :active_storage_blobs, :service_name, :string, null: false, default: 'local'
6 | create_table :active_storage_variant_records do |t|
7 | t.belongs_to :blob, null: false, index: false
8 | t.string :variation_digest, null: false
9 |
10 | t.index %i[blob_id variation_digest], name: 'index_active_storage_variant_records_uniqueness', unique: true
11 | end
12 | end
13 | end
14 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/_transitions.scss:
--------------------------------------------------------------------------------
1 | .fade {
2 | @include transition($transition-fade);
3 |
4 | &:not(.show) {
5 | opacity: 0;
6 | }
7 | }
8 |
9 | // scss-docs-start collapse-classes
10 | .collapse {
11 | &:not(.show) {
12 | display: none;
13 | }
14 | }
15 |
16 | .collapsing {
17 | height: 0;
18 | overflow: hidden;
19 | @include transition($transition-collapse);
20 |
21 | &.collapse-horizontal {
22 | width: 0;
23 | height: auto;
24 | @include transition($transition-collapse-width);
25 | }
26 | }
27 | // scss-docs-end collapse-classes
28 |
--------------------------------------------------------------------------------
/spec/dummy_app/webpack.config.js:
--------------------------------------------------------------------------------
1 | const path = require("path");
2 | const webpack = require("webpack");
3 |
4 | module.exports = {
5 | mode: "production",
6 | devtool: "source-map",
7 | entry: {
8 | application: "./app/javascript/application.js",
9 | rails_admin: "./app/javascript/rails_admin.js",
10 | },
11 | output: {
12 | filename: "[name].js",
13 | sourceMapFilename: "[name].js.map",
14 | path: path.resolve(__dirname, "app/assets/builds"),
15 | },
16 | plugins: [
17 | new webpack.optimize.LimitChunkCountPlugin({
18 | maxChunks: 1,
19 | }),
20 | ],
21 | };
22 |
--------------------------------------------------------------------------------
/src/rails_admin/sidescroll.js:
--------------------------------------------------------------------------------
1 | "use strict";
2 |
3 | {
4 | document.addEventListener("rails_admin.dom_ready", () => {
5 | const scroller = document.getElementById("sidescroll");
6 | if (!scroller) {
7 | return;
8 | }
9 |
10 | scroller.querySelectorAll("tr").forEach((tr, index) => {
11 | let firstPosition;
12 | tr.querySelectorAll("th.sticky, td.sticky").forEach((td, idx) => {
13 | if (idx === 0) {
14 | firstPosition = td.offsetLeft;
15 | }
16 | td.style.left = `${td.offsetLeft - firstPosition}px`;
17 | });
18 | });
19 | });
20 | }
21 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/factories/action_text.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields'
4 | require 'rails_admin/config/fields/types'
5 |
6 | RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
7 | if defined?(::ActionText) && properties.try(:association?) && (match = /\Arich_text_(.+)\Z/.match properties.name) && properties.klass.to_s == 'ActionText::RichText'
8 | field = RailsAdmin::Config::Fields::Types.load(:action_text).new(parent, match[1], properties)
9 | fields << field
10 | true
11 | else
12 | false
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/frontend/entrypoints/rails_admin.js:
--------------------------------------------------------------------------------
1 | import "~/stylesheets/rails_admin.scss";
2 | import "rails_admin/src/rails_admin/base";
3 | import "flatpickr/dist/l10n/fr.js";
4 | import "trix";
5 | import "@rails/actiontext";
6 | import * as ActiveStorage from "@rails/activestorage";
7 | ActiveStorage.start();
8 |
9 | window.domReadyTriggered = [];
10 |
11 | document.addEventListener("rails_admin.dom_ready", function () {
12 | window.domReadyTriggered.push("plainjs/dot");
13 | });
14 |
15 | $(document).on("rails_admin.dom_ready", function () {
16 | window.domReadyTriggered.push("jquery/dot");
17 | });
18 |
--------------------------------------------------------------------------------
/spec/integration/actions/show_in_app_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'ShowInApp action', type: :request do
6 | subject { page }
7 |
8 | describe 'link' do
9 | let!(:player) { FactoryBot.create :player }
10 |
11 | it 'has the data-turbo: false attribute' do
12 | visit index_path(model_name: 'player')
13 | is_expected.to have_selector(%(li[title="Show in app"] a[data-turbo="false"]))
14 | click_link 'Show'
15 | is_expected.to have_selector(%(a[data-turbo="false"]), text: 'Show in app')
16 | end
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/assets/stylesheets/application.css:
--------------------------------------------------------------------------------
1 | /*
2 | * This is a manifest file that'll be compiled into application.css, which will include all the files
3 | * listed below.
4 | *
5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
6 | * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
7 | *
8 | * You're free to add application-wide styles to this file and they'll appear at the top of the
9 | * compiled file, but it's generally better to create a new file per style scope.
10 | *
11 | *= require_self
12 | */
13 |
--------------------------------------------------------------------------------
/config/initializers/active_record_extensions.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | ActiveSupport.on_load(:active_record) do
4 | module ActiveRecord
5 | class Base
6 | def self.rails_admin(&block)
7 | RailsAdmin.config(self, &block)
8 | end
9 |
10 | def rails_admin_default_object_label_method
11 | new_record? ? "new #{self.class}" : "#{self.class} ##{id}"
12 | end
13 |
14 | def safe_send(value)
15 | if has_attribute?(value)
16 | read_attribute(value)
17 | else
18 | send(value)
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/nested_field_test.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class NestedFieldTest < ActiveRecord::Base
4 | belongs_to :field_test, optional: true, inverse_of: :nested_field_tests
5 | belongs_to :another_field_test, optional: true, inverse_of: :nested_field_tests
6 | has_one :comment, as: :commentable
7 | has_many :deeply_nested_field_tests, inverse_of: :nested_field_test
8 | accepts_nested_attributes_for :comment, allow_destroy: true, reject_if: proc { |attributes| attributes['content'].blank? }
9 | accepts_nested_attributes_for :deeply_nested_field_tests, allow_destroy: true
10 | end
11 |
--------------------------------------------------------------------------------
/spec/dummy_app/fly.toml:
--------------------------------------------------------------------------------
1 | # fly.toml app configuration file generated for rails-admin on 2023-08-06T18:22:31+09:00
2 | #
3 | # See https://fly.io/docs/reference/configuration/ for information about how to use this file.
4 | #
5 |
6 | app = "rails-admin"
7 | primary_region = "iad"
8 | console_command = "/rails/bin/rails console"
9 |
10 | [build]
11 |
12 | [http_service]
13 | internal_port = 3000
14 | force_https = true
15 | auto_stop_machines = true
16 | auto_start_machines = true
17 | min_machines_running = 0
18 | processes = ["app"]
19 |
20 | [[statics]]
21 | guest_path = "/rails/public"
22 | url_prefix = "/"
23 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_reset-text.scss:
--------------------------------------------------------------------------------
1 | @mixin reset-text {
2 | font-family: $font-family-base;
3 | // We deliberately do NOT reset font-size or overflow-wrap / word-wrap.
4 | font-style: normal;
5 | font-weight: $font-weight-normal;
6 | line-height: $line-height-base;
7 | text-align: left; // Fallback for where `start` is not supported
8 | text-align: start;
9 | text-decoration: none;
10 | text-shadow: none;
11 | text-transform: none;
12 | letter-spacing: normal;
13 | word-break: normal;
14 | word-spacing: normal;
15 | white-space: normal;
16 | line-break: auto;
17 | }
18 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/mongoid/shrine_versioning_uploader.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ShrineVersioningUploader < Shrine
4 | plugin :mongoid
5 |
6 | plugin :cached_attachment_data
7 | plugin :determine_mime_type
8 | plugin :pretty_location
9 | plugin :remove_attachment
10 |
11 | if Gem.loaded_specs['shrine'].version >= Gem::Version.create('3')
12 | plugin :derivatives
13 |
14 | Attacher.derivatives_processor do |original|
15 | {
16 | thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
17 | }
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/shrine_versioning_uploader.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ShrineVersioningUploader < Shrine
4 | plugin :activerecord
5 |
6 | plugin :cached_attachment_data
7 | plugin :determine_mime_type
8 | plugin :pretty_location
9 | plugin :remove_attachment
10 |
11 | if Gem.loaded_specs['shrine'].version >= Gem::Version.create('3')
12 | plugin :derivatives
13 |
14 | Attacher.derivatives_processor do |original|
15 | {
16 | thumb: FakeIO.new('', filename: File.basename(original.path), content_type: File.extname(original.path)),
17 | }
18 | end
19 | end
20 | end
21 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/cors.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Avoid CORS issues when API is called from the frontend app.
6 | # Handle Cross-Origin Resource Sharing (CORS) in order to accept cross-origin AJAX requests.
7 |
8 | # Read more: https://github.com/cyu/rack-cors
9 |
10 | # Rails.application.config.middleware.insert_before 0, Rack::Cors do
11 | # allow do
12 | # origins 'example.com'
13 | #
14 | # resource '*',
15 | # headers: :any,
16 | # methods: [:get, :post, :put, :patch, :delete, :options, :head]
17 | # end
18 | # end
19 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/20110901131551_change_division_primary_key.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class ChangeDivisionPrimaryKey < ActiveRecord::Migration[5.0]
4 | def up
5 | drop_table :divisions
6 | create_table :divisions, primary_key: 'custom_id' do |t|
7 | t.timestamps null: false
8 | t.integer :league_id
9 | t.string :name, limit: 50, null: false
10 | end
11 | end
12 |
13 | def down
14 | drop_table :divisions
15 | create_table :divisions do |t|
16 | t.timestamps null: false
17 | t.integer :league_id
18 | t.string :name, limit: 50, null: false
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/.github/ISSUE_TEMPLATE/bug_report.md:
--------------------------------------------------------------------------------
1 | ---
2 | name: Bug report
3 | about: Create a report to help us improve
4 | title: ""
5 | labels: ""
6 | assignees: ""
7 | ---
8 |
9 | **Describe the bug**
10 | A clear and concise description of what the bug is.
11 |
12 | **Reproduction steps**
13 | Steps to reproduce the issue seen.
14 |
15 | **Expected behavior**
16 | A clear and concise description of what you expected to happen.
17 |
18 | **Additional context**
19 |
20 | - `rails` version:
21 | - `rails_admin` version:
22 | - `rails_admin` npm package version:
23 | - full stack trace (if there's an exception)
24 |
25 | Add any other context about the problem here.
26 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/wrap_parameters.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # This file contains settings for ActionController::ParamsWrapper which
6 | # is enabled by default.
7 |
8 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
9 | ActiveSupport.on_load(:action_controller) do
10 | wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
11 | end
12 |
13 | # To enable root element in JSON for ActiveRecord objects.
14 | # ActiveSupport.on_load(:active_record) do
15 | # self.include_root_in_json = true
16 | # end
17 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/decimal.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/types/numeric'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class Decimal < RailsAdmin::Config::Fields::Types::Numeric
10 | # Register field type for the type loader
11 | RailsAdmin::Config::Fields::Types.register(self)
12 |
13 | register_instance_option :html_attributes do
14 | {
15 | required: required?,
16 | step: 'any',
17 | }
18 | end
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/float.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/types/numeric'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class Float < RailsAdmin::Config::Fields::Types::Numeric
10 | # Register field type for the type loader
11 | RailsAdmin::Config::Fields::Types.register(self)
12 |
13 | register_instance_option :html_attributes do
14 | {
15 | required: required?,
16 | step: 'any',
17 | }
18 | end
19 | end
20 | end
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/dragonfly.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'dragonfly'
4 |
5 | # Logger
6 | Dragonfly.logger = Rails.logger
7 |
8 | # Configure
9 | Dragonfly.app.configure do
10 | plugin :imagemagick
11 |
12 | protect_from_dos_attacks true
13 | secret '904547b2be647f0e11a76933b3220d6bd2fb83f380ac760125e4daa3b9504b4e'
14 |
15 | url_format '/media/:job/:name'
16 |
17 | datastore(:file,
18 | root_path: Rails.root.join('public/system/dragonfly', Rails.env),
19 | server_root: Rails.root.join('public'))
20 | end
21 |
22 | # Mount as middleware
23 | Rails.application.middleware.use Dragonfly::Middleware
24 |
--------------------------------------------------------------------------------
/spec/dummy_app/db/migrate/00000000000012_add_avatar_columns_to_user.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddAvatarColumnsToUser < ActiveRecord::Migration[5.0]
4 | def self.up
5 | add_column :users, :avatar_file_name, :string
6 | add_column :users, :avatar_content_type, :string
7 | add_column :users, :avatar_file_size, :integer
8 | add_column :users, :avatar_updated_at, :datetime
9 | end
10 |
11 | def self.down
12 | remove_column :users, :avatar_file_name
13 | remove_column :users, :avatar_content_type
14 | remove_column :users, :avatar_file_size
15 | remove_column :users, :avatar_updated_at
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields, mongoid: true do
6 | describe '.factory for self.referentials belongs_to' do
7 | it 'associates belongs_to _id foreign_key to a belongs_to association' do
8 | class MongoTree
9 | include Mongoid::Document
10 | has_many :children, class_name: name, foreign_key: :parent_id
11 | belongs_to :parent, class_name: name
12 | end
13 |
14 | expect(RailsAdmin.config(MongoTree).fields.detect { |f| f.name == :parent }.type).to eq :belongs_to_association
15 | end
16 | end
17 | end
18 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/rails_admin/custom/variables.scss:
--------------------------------------------------------------------------------
1 | /*
2 | Customize Sass variables from Twitter-Bootstrap/RailsAdmin theme or add new ones for your own use.
3 | Copy this file to your app/assets/rails_admin/custom/variables.scss, leave this one untouched
4 | Don't require it in your application.rb
5 |
6 | Available variables to use/override:
7 |
8 | https://github.com/twbs/bootstrap-sass/blob/master/assets/stylesheets/bootstrap/_variables.scss
9 | https://github.com/railsadminteam/rails_admin/blob/master/src/rails_admin/styles/base/variables.scss
10 | Plus the ones from your themes.
11 |
12 | Test me: pink links
13 |
14 | $link-color: #F0F;
15 | */
16 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/views/layouts/application.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | for [#{default_value}] >", :yellow).presence || default_value
16 | end
17 | end
18 | end
19 | end
20 | end
21 | end
22 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/hidden.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/types/string_like'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class Hidden < StringLike
10 | RailsAdmin::Config::Fields::Types.register(self)
11 |
12 | register_instance_option :view_helper do
13 | :hidden_field
14 | end
15 |
16 | register_instance_option :label do
17 | false
18 | end
19 |
20 | register_instance_option :help do
21 | false
22 | end
23 |
24 | def generic_help
25 | false
26 | end
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/favorite_player.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | if ActiveRecord.gem_version >= Gem::Version.new('7.1') || defined?(CompositePrimaryKeys)
4 | class FavoritePlayer < ActiveRecord::Base
5 | if defined?(CompositePrimaryKeys)
6 | self.primary_keys = :fan_id, :team_id, :player_id
7 | else
8 | self.primary_key = :fan_id, :team_id, :player_id
9 | end
10 | if defined?(CompositePrimaryKeys) || ActiveRecord.gem_version >= Gem::Version.new('7.2')
11 | belongs_to :fanship, foreign_key: %i[fan_id team_id], inverse_of: :favorite_players
12 | else
13 | belongs_to :fanship, query_constraints: %i[fan_id team_id], inverse_of: :favorite_players
14 | end
15 |
16 | belongs_to :player
17 | end
18 | end
19 |
--------------------------------------------------------------------------------
/spec/rails_admin/extentions/paper_trail/version_proxy_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Extensions::PaperTrail::VersionProxy, active_record: true do
6 | describe '#username' do
7 | subject { described_class.new(version, user_class).username }
8 |
9 | let(:version) { double(whodunnit: :the_user) }
10 | let(:user_class) { double(find: user) }
11 |
12 | context 'when found user has email' do
13 | let(:user) { double(email: :mail) }
14 | it { is_expected.to eq(:mail) }
15 | end
16 |
17 | context 'when found user does not have email' do
18 | let(:user) { double } # no email method
19 |
20 | it { is_expected.to eq(:the_user) }
21 | end
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/factories/password.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields'
4 | require 'rails_admin/config/fields/types/password'
5 |
6 | # Register a custom field factory for properties named as password. More property
7 | # names can be registered in RailsAdmin::Config::Fields::Password.column_names
8 | # array.
9 | #
10 | # @see RailsAdmin::Config::Fields::Types::Password.column_names
11 | # @see RailsAdmin::Config::Fields.register_factory
12 | RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
13 | if [:password].include?(properties.name)
14 | fields << RailsAdmin::Config::Fields::Types::Password.new(parent, properties.name, properties)
15 | true
16 | else
17 | false
18 | end
19 | end
20 |
--------------------------------------------------------------------------------
/spec/dummy_app/.gitignore:
--------------------------------------------------------------------------------
1 | # See http://help.github.com/ignore-files/ for more about ignoring files.
2 | #
3 | # If you find yourself ignoring temporary files generated by your text editor
4 | # or operating system, you probably want to add a global ignore instead:
5 | # git config --global core.excludesfile ~/.gitignore_global
6 |
7 | # Ignore bundler config
8 | /.bundle
9 |
10 | /app/assets/builds/*
11 | !/app/assets/builds/.keep
12 |
13 | # Ignore the default SQLite database.
14 | /db/*.sqlite3
15 |
16 | # Ignore all logfiles and tempfiles.
17 | /log/*.log
18 | /tmp
19 |
20 | /public/system
21 |
22 | /public/assets
23 | /public/packs
24 | /public/packs-test
25 | /public/vite*
26 | /node_modules
27 | /yarn-error.log
28 | /yarn.lock
29 | yarn-debug.log*
30 | .yarn-integrity
31 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/inflections.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Add new inflection rules using the following format. Inflections
6 | # are locale specific, and you may define rules for as many different
7 | # locales as you wish. All of these examples are active by default:
8 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
9 | # inflect.plural /^(ox)$/i, '\1en'
10 | # inflect.singular /^(ox)en/i, '\1'
11 | # inflect.irregular 'person', 'people'
12 | # inflect.uncountable %w( fish sheep )
13 | # end
14 |
15 | # These inflection rules are supported but not enabled by default:
16 | # ActiveSupport::Inflector.inflections(:en) do |inflect|
17 | # inflect.acronym 'RESTful'
18 | # end
19 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/secret_token.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Your secret key is used for verifying the integrity of signed cookies.
6 | # If you change this key, all old signed cookies will become invalid!
7 |
8 | # Make sure the secret is at least 30 characters and all random,
9 | # no regular words or you'll be exposed to dictionary attacks.
10 | # You can use `rake secret` to generate a secure secret key.
11 |
12 | # Make sure your secret_key_base is kept private
13 | # if you're sharing your code publicly.
14 | DummyApp::Application.config.secret_key_base = '11cefe91820bbc7c4ef81114d5b8e9237bce9c1d5d1b4a2f8b333e151dfa3ff43b3db8d0d3b4dc414f15113f28c5d779e829c3cb3fbcdc7c5a94fe7fdcb2c81c'
15 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/hideable.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | module Config
5 | # Defines a visibility configuration
6 | module Hideable
7 | # Visibility defaults to true.
8 | def self.included(klass)
9 | klass.register_instance_option :visible? do
10 | !root.try :excluded?
11 | end
12 | end
13 |
14 | # Reader whether object is hidden.
15 | def hidden?
16 | !visible
17 | end
18 |
19 | # Writer to hide object.
20 | def hide(&block)
21 | visible block ? proc { instance_eval(&block) == false } : false
22 | end
23 |
24 | # Writer to show field.
25 | def show(&block)
26 | visible block || true
27 | end
28 | end
29 | end
30 | end
31 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/_grid.scss:
--------------------------------------------------------------------------------
1 | // Row
2 | //
3 | // Rows contain your columns.
4 |
5 | @if $enable-grid-classes {
6 | .row {
7 | @include make-row();
8 |
9 | > * {
10 | @include make-col-ready();
11 | }
12 | }
13 | }
14 |
15 | @if $enable-cssgrid {
16 | .grid {
17 | display: grid;
18 | grid-template-rows: repeat(var(--#{$variable-prefix}rows, 1), 1fr);
19 | grid-template-columns: repeat(var(--#{$variable-prefix}columns, #{$grid-columns}), 1fr);
20 | gap: var(--#{$variable-prefix}gap, #{$grid-gutter-width});
21 |
22 | @include make-cssgrid();
23 | }
24 | }
25 |
26 |
27 | // Columns
28 | //
29 | // Common styles for small and large grid columns
30 |
31 | @if $enable-grid-classes {
32 | @include make-grid-columns();
33 | }
34 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/_badge.scss:
--------------------------------------------------------------------------------
1 | // Base class
2 | //
3 | // Requires one of the contextual, color modifier classes for `color` and
4 | // `background-color`.
5 |
6 | .badge {
7 | display: inline-block;
8 | padding: $badge-padding-y $badge-padding-x;
9 | @include font-size($badge-font-size);
10 | font-weight: $badge-font-weight;
11 | line-height: 1;
12 | color: $badge-color;
13 | text-align: center;
14 | white-space: nowrap;
15 | vertical-align: baseline;
16 | @include border-radius($badge-border-radius);
17 | @include gradient-bg();
18 |
19 | // Empty badges collapse automatically
20 | &:empty {
21 | display: none;
22 | }
23 | }
24 |
25 | // Quick fix for badges in buttons
26 | .btn .badge {
27 | position: relative;
28 | top: -1px;
29 | }
30 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/proxyable.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/proxyable/proxy'
4 | module RailsAdmin
5 | module Config
6 | module Proxyable
7 | def bindings
8 | Thread.current[:rails_admin_bindings] ||= {}
9 | Thread.current[:rails_admin_bindings][self]
10 | end
11 |
12 | def bindings=(new_bindings)
13 | Thread.current[:rails_admin_bindings] ||= {}
14 | if new_bindings.nil?
15 | Thread.current[:rails_admin_bindings].delete(self)
16 | else
17 | Thread.current[:rails_admin_bindings][self] = new_bindings
18 | end
19 | end
20 |
21 | def with(bindings = {})
22 | RailsAdmin::Config::Proxyable::Proxy.new(self, bindings)
23 | end
24 | end
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/spec/dummy_app/config/initializers/assets.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | # Be sure to restart your server when you modify this file.
4 |
5 | # Version of your assets, change this if you want to expire all your assets.
6 | Rails.application.config.assets.version = '1.0' if Rails.application.config.respond_to?(:assets)
7 |
8 | # Add additional assets to the asset load path
9 | # Rails.application.config.assets.paths << Emoji.images_path
10 | Rails.application.config.assets.paths << Rails.root.join('node_modules/@fortawesome/fontawesome-free/webfonts') if Rails.application.config.respond_to?(:assets)
11 |
12 | # Precompile additional assets.
13 | # application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
14 | # Rails.application.config.assets.precompile += %w( search.js )
15 |
--------------------------------------------------------------------------------
/config/routes.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | RailsAdmin::Engine.routes.draw do
4 | controller 'main' do
5 | RailsAdmin::Config::Actions.all(:root).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }
6 | scope ':model_name' do
7 | RailsAdmin::Config::Actions.all(:collection).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }
8 | post '/bulk_action', action: :bulk_action, as: 'bulk_action'
9 | scope ':id' do
10 | RailsAdmin::Config::Actions.all(:member).each { |action| match "/#{action.route_fragment}", action: action.action_name, as: action.action_name, via: action.http_methods }
11 | end
12 | end
13 | end
14 | end
15 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/string_like.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/base'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class StringLike < RailsAdmin::Config::Fields::Base
10 | register_instance_option :filter_operators do
11 | %w[_discard like not_like is starts_with ends_with] + (required? ? [] : %w[_separator _present _blank])
12 | end
13 |
14 | register_instance_option :treat_empty_as_nil? do
15 | properties.try(:nullable?)
16 | end
17 |
18 | def parse_input(params)
19 | params[name] = params[name].presence if params.key?(name) && treat_empty_as_nil?
20 | end
21 | end
22 | end
23 | end
24 | end
25 | end
26 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_transition.scss:
--------------------------------------------------------------------------------
1 | // stylelint-disable property-disallowed-list
2 | @mixin transition($transition...) {
3 | @if length($transition) == 0 {
4 | $transition: $transition-base;
5 | }
6 |
7 | @if length($transition) > 1 {
8 | @each $value in $transition {
9 | @if $value == null or $value == none {
10 | @warn "The keyword 'none' or 'null' must be used as a single argument.";
11 | }
12 | }
13 | }
14 |
15 | @if $enable-transitions {
16 | @if nth($transition, 1) != null {
17 | transition: $transition;
18 | }
19 |
20 | @if $enable-reduced-motion and nth($transition, 1) != null and nth($transition, 1) != none {
21 | @media (prefers-reduced-motion: reduce) {
22 | transition: none;
23 | }
24 | }
25 | }
26 | }
27 |
--------------------------------------------------------------------------------
/spec/integration/fields/shrine_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'Shrine field', type: :request, active_record: true do
6 | subject { page }
7 | before do
8 | RailsAdmin.config FieldTest do
9 | edit do
10 | field :string_field
11 | field :shrine_asset
12 | end
13 | end
14 | end
15 |
16 | it 'supports caching an uploaded file', js: true do
17 | visit new_path(model_name: 'field_test')
18 | attach_file 'Shrine asset', file_path('test.jpg')
19 | fill_in 'field_test[string_field]', with: 'Invalid'
20 | click_button 'Save'
21 | expect(page).to have_content 'Field test failed to be created'
22 | fill_in 'field_test[string_field]', with: ''
23 | click_button 'Save'
24 | expect(FieldTest.first.shrine_asset).to exist
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'active_support/core_ext/string/inflections'
4 | require 'rails_admin/config/fields'
5 | require 'rails_admin/config/fields/association'
6 |
7 | module RailsAdmin
8 | module Config
9 | module Fields
10 | module Types
11 | @@registry = {}
12 |
13 | def self.load(type)
14 | @@registry.fetch(type.to_sym) { raise "Unsupported field datatype: #{type}" }
15 | end
16 |
17 | def self.register(type, klass = nil)
18 | if klass.nil? && type.is_a?(Class)
19 | klass = type
20 | type = klass.name.to_s.demodulize.underscore
21 | end
22 | @@registry[type.to_sym] = klass
23 | end
24 |
25 | require 'rails_admin/config/fields/types/all'
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/spec/dummy_app/bin/vite:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | # frozen_string_literal: true
3 |
4 | #
5 | # This file was generated by Bundler.
6 | #
7 | # The application 'vite' is installed as part of a gem, and
8 | # this file is here to facilitate running it.
9 | #
10 |
11 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__)
12 |
13 | bundle_binstub = File.expand_path("bundle", __dir__)
14 |
15 | if File.file?(bundle_binstub)
16 | if File.read(bundle_binstub, 300) =~ /This file was generated by Bundler/
17 | load(bundle_binstub)
18 | else
19 | abort("Your `bin/bundle` was not generated by Bundler, so this binstub cannot run.
20 | Replace `bin/bundle` by running `bundle binstubs bundler --force`, then run this command again.")
21 | end
22 | end
23 |
24 | require "rubygems"
25 | require "bundler/setup"
26 |
27 | load Gem.bin_path("vite_ruby", "vite")
28 |
--------------------------------------------------------------------------------
/lib/rails_admin/adapters/mongoid/bson.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'mongoid'
4 |
5 | module RailsAdmin
6 | module Adapters
7 | module Mongoid
8 | class Bson
9 | OBJECT_ID =
10 | if defined?(Moped::BSON)
11 | Moped::BSON::ObjectId
12 | elsif defined?(BSON::ObjectId)
13 | BSON::ObjectId
14 | end
15 |
16 | class << self
17 | def parse_object_id(value)
18 | OBJECT_ID.from_string(value)
19 | rescue StandardError => e
20 | raise e if %w[
21 | Moped::Errors::InvalidObjectId
22 | BSON::ObjectId::Invalid
23 | BSON::InvalidObjectId
24 | BSON::Error::InvalidObjectId
25 | ].exclude?(e.class.to_s)
26 | end
27 | end
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/spec/integration/fields/carrierwave_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'Carrierwave field', type: :request, active_record: true do
6 | subject { page }
7 | before do
8 | RailsAdmin.config FieldTest do
9 | edit do
10 | field :string_field
11 | field :carrierwave_asset
12 | end
13 | end
14 | end
15 |
16 | it 'supports caching an uploaded file' do
17 | visit new_path(model_name: 'field_test')
18 | attach_file 'Carrierwave asset', file_path('test.jpg')
19 | fill_in 'field_test[string_field]', with: 'Invalid'
20 | click_button 'Save'
21 | expect(page).to have_content 'Field test failed to be created'
22 | fill_in 'field_test[string_field]', with: ''
23 | click_button 'Save'
24 | expect(FieldTest.first.carrierwave_asset.file).to exist
25 | end
26 | end
27 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/fanship.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | if ActiveRecord.gem_version >= Gem::Version.new('7.1') || defined?(CompositePrimaryKeys)
4 | class Fanship < ActiveRecord::Base
5 | self.table_name = :fans_teams
6 | if defined?(CompositePrimaryKeys)
7 | self.primary_keys = :fan_id, :team_id
8 | else
9 | self.primary_key = :fan_id, :team_id
10 | end
11 | if defined?(CompositePrimaryKeys) || ActiveRecord.gem_version >= Gem::Version.new('7.2')
12 | has_many :favorite_players, foreign_key: %i[fan_id team_id], inverse_of: :fanship
13 | else
14 | has_many :favorite_players, query_constraints: %i[fan_id team_id], inverse_of: :fanship
15 | end
16 |
17 | belongs_to :fan, inverse_of: :fanships, optional: true
18 | belongs_to :team, optional: true
19 | end
20 | else
21 | class Fanship; end
22 | end
23 |
--------------------------------------------------------------------------------
/spec/dummy_app/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "dummy_app",
3 | "private": true,
4 | "version": "0.1.0",
5 | "dependencies": {
6 | "@babel/plugin-proposal-private-methods": "^7.18.6",
7 | "@babel/plugin-proposal-private-property-in-object": "^7.21.11",
8 | "@rails/actiontext": "^7.0.3-1",
9 | "@rails/activestorage": "^7.0.3-1",
10 | "@rails/webpacker": "5.4.3",
11 | "rails_admin": "file:../..",
12 | "trix": "^2.0.0-beta.0",
13 | "webpack": "^4.46.0",
14 | "webpack-cli": "^3.3.12"
15 | },
16 | "devDependencies": {
17 | "vite": "^5.0",
18 | "vite-plugin-ruby": ">=5.0 <6",
19 | "webpack-dev-server": "^3"
20 | },
21 | "scripts": {
22 | "build": "webpack --config webpack.config.js",
23 | "build:css": "sass ./app/assets/stylesheets/rails_admin.scss:./app/assets/builds/rails_admin.css --no-source-map --load-path=node_modules"
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/timestamp_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::Timestamp, active_record: true do
6 | it_behaves_like 'a generic field type', :timestamp_field, :timestamp
7 |
8 | describe '#parse_input' do
9 | before :each do
10 | @object = FactoryBot.create(:field_test)
11 | @time = ::Time.now.getutc
12 | @field = RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :timestamp_field }
13 | end
14 |
15 | after :each do
16 | Time.zone = 'UTC'
17 | end
18 |
19 | it 'reads %B %d, %Y %H:%M' do
20 | @object.timestamp_field = @field.parse_input(timestamp_field: @time.strftime('%B %d, %Y %H:%M'))
21 | expect(@object.timestamp_field.strftime('%Y-%m-%d %H:%M')).to eq(@time.strftime('%Y-%m-%d %H:%M'))
22 | end
23 | end
24 | end
25 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/bson_object_id_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::BsonObjectId do
6 | it_behaves_like 'a generic field type', :string_field, :bson_object_id
7 |
8 | describe '#parse_value' do
9 | let(:bson) { RailsAdmin::Adapters::Mongoid::Bson::OBJECT_ID.new }
10 | let(:field) do
11 | RailsAdmin.config(FieldTest).fields.detect do |f|
12 | f.name == :bson_object_id_field
13 | end
14 | end
15 |
16 | before :each do
17 | RailsAdmin.config do |config|
18 | config.model FieldTest do
19 | field :bson_object_id_field, :bson_object_id
20 | end
21 | end
22 | end
23 |
24 | it 'parse valid bson_object_id', mongoid: true do
25 | expect(field.parse_value(bson.to_s)).to eq bson
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/carrierwave_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::Carrierwave do
6 | it_behaves_like 'a generic field type', :string_field, :carrierwave
7 |
8 | describe '#thumb_method' do
9 | before do
10 | RailsAdmin.config FieldTest do
11 | field :carrierwave_asset, :carrierwave
12 | end
13 | end
14 |
15 | let :rails_admin_field do
16 | RailsAdmin.config('FieldTest').fields.detect do |f|
17 | f.name == :carrierwave_asset
18 | end.with(
19 | object: FieldTest.new(string_field: 'dummy.txt'),
20 | view: ApplicationController.new.view_context,
21 | )
22 | end
23 |
24 | it 'auto-detects thumb-like version name' do
25 | expect(rails_admin_field.thumb_method).to eq :thumb
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/user.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class User < ActiveRecord::Base
4 | # Include default devise modules. Others available are:
5 | # :token_authenticatable, :confirmable, :lockable and :timeoutable
6 | devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable
7 |
8 | if ActiveRecord.gem_version < Gem::Version.new('7.1')
9 | serialize :roles, Array
10 | else
11 | serialize :roles, coder: YAML, type: Array
12 | end
13 |
14 | # Add Paperclip support for avatars
15 | has_attached_file :avatar, styles: {medium: '300x300>', thumb: '100x100>'}
16 |
17 | attr_accessor :delete_avatar
18 |
19 | before_validation { self.avatar = nil if delete_avatar == '1' }
20 |
21 | def attr_accessible_role
22 | :custom_role
23 | end
24 |
25 | def roles_enum
26 | %i[admin user]
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/types/serialized.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/types/text'
4 |
5 | module RailsAdmin
6 | module Config
7 | module Fields
8 | module Types
9 | class Serialized < RailsAdmin::Config::Fields::Types::Text
10 | # Register field type for the type loader
11 | RailsAdmin::Config::Fields::Types.register(self)
12 |
13 | register_instance_option :formatted_value do
14 | RailsAdmin.yaml_dump(value) unless value.nil?
15 | end
16 |
17 | def parse_value(value)
18 | value.present? ? (RailsAdmin.yaml_load(value) || nil) : nil
19 | end
20 |
21 | def parse_input(params)
22 | params[name] = parse_value(params[name]) if params[name].is_a?(::String)
23 | end
24 | end
25 | end
26 | end
27 | end
28 | end
29 |
--------------------------------------------------------------------------------
/lib/rails_admin/support/hash_helper.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | class HashHelper
5 | def self.symbolize(obj)
6 | case obj
7 | when Array
8 | obj.each_with_object([]) do |val, res|
9 | res << case val
10 | when Hash, Array then symbolize(val)
11 | when String then val.to_sym
12 | else val
13 | end
14 | end
15 | when Hash
16 | obj.each_with_object({}) do |(key, val), res|
17 | nkey = key.is_a?(String) ? key.to_sym : key
18 | nval =
19 | case val
20 | when Hash, Array then symbolize(val)
21 | when String then val.to_sym
22 | else val
23 | end
24 | res[nkey] = nval
25 | end
26 | else
27 | obj
28 | end
29 | end
30 | end
31 | end
32 |
--------------------------------------------------------------------------------
/app/views/rails_admin/main/_form_file_upload.html.erb:
--------------------------------------------------------------------------------
1 | <% file = field.value %>
2 | <% if field.cache_method %>
3 | <%= form.hidden_field(field.cache_method, value: field.cache_value) %>
4 | <% end %>
5 |
6 | <% if value = field.pretty_value %>
7 | <%= value %>
8 | <% end %>
9 | <%= form.file_field(field.name, {data: {fileupload: true}}.deep_merge(field.html_attributes)) %>
10 |
11 | <% if field.optional? && field.errors.blank? && file && field.delete_method %>
12 |
13 |
14 | <%= I18n.t('admin.actions.delete.link', object_label: field.label) %>
15 |
16 | <%= form.check_box(field.delete_method, style: 'display:none;') %>
17 | <% end %>
18 |
--------------------------------------------------------------------------------
/app/views/rails_admin/main/bulk_delete.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= I18n.t('admin.form.bulk_delete') %>
3 |
4 |
5 | <%= render partial: "delete_notice", collection: @objects %>
6 |
7 | <%= form_tag bulk_delete_path(model_name: @abstract_model.to_param, bulk_ids: @objects.map(&:id)), method: :delete do %>
8 |
9 |
10 |
14 |
18 |
19 | <% end %>
20 |
--------------------------------------------------------------------------------
/spec/dummy_app/bin/update:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby
2 | require 'pathname'
3 | require 'fileutils'
4 | include FileUtils
5 |
6 | # path to your application root.
7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
8 |
9 | def system!(*args)
10 | system(*args) || abort("\n== Command #{args} failed ==")
11 | end
12 |
13 | chdir APP_ROOT do
14 | # This script is a way to update your development environment automatically.
15 | # Add necessary update steps to this file.
16 |
17 | puts '== Installing dependencies =='
18 | system! 'gem install bundler --conservative'
19 | system 'bundle check' or system! 'bundle install'
20 |
21 | puts "\n== Updating database =="
22 | system! 'bin/rails db:migrate'
23 |
24 | puts "\n== Removing old logs and tempfiles =="
25 | system! 'bin/rails log:clear tmp:clear'
26 |
27 | puts "\n== Restarting application server =="
28 | system! 'bin/rails restart'
29 | end
30 |
--------------------------------------------------------------------------------
/spec/dummy_app/public/500.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | We're sorry, but something went wrong (500)
5 |
26 |
27 |
28 |
29 |
30 |
31 |
We're sorry, but something went wrong.
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/app/views/layouts/rails_admin/content.html.erb:
--------------------------------------------------------------------------------
1 |
2 | <%= "#{@abstract_model.try(:pretty_name) || @page_name} | #{[_get_plugin_name[0] || 'Rails', _get_plugin_name[1] || 'Admin'].join(' ')}" %>
3 |
4 |
5 |
6 | <%= @page_name %>
7 |
8 |
9 | <% flash && flash.each do |key, value| %>
10 |
11 | <%= value %>
12 |
13 |
14 | <% end %>
15 |
18 |
19 | <%= menu_for((@abstract_model ? (@object.try(:persisted?) ? :member : :collection) : :root), @abstract_model, @object) %>
20 | <%= content_for :contextual_tabs %>
21 |
22 | <%= yield %>
23 |
--------------------------------------------------------------------------------
/vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_pagination.scss:
--------------------------------------------------------------------------------
1 | // Pagination
2 |
3 | // scss-docs-start pagination-mixin
4 | @mixin pagination-size($padding-y, $padding-x, $font-size, $border-radius) {
5 | .page-link {
6 | padding: $padding-y $padding-x;
7 | @include font-size($font-size);
8 | }
9 |
10 | .page-item {
11 | @if $pagination-margin-start == (-$pagination-border-width) {
12 | &:first-child {
13 | .page-link {
14 | @include border-start-radius($border-radius);
15 | }
16 | }
17 |
18 | &:last-child {
19 | .page-link {
20 | @include border-end-radius($border-radius);
21 | }
22 | }
23 | } @else {
24 | //Add border-radius to all pageLinks in case they have left margin
25 | .page-link {
26 | @include border-radius($border-radius);
27 | }
28 | }
29 | }
30 | }
31 | // scss-docs-end pagination-mixin
32 |
--------------------------------------------------------------------------------
/spec/integration/authentication/devise_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'RailsAdmin Devise Authentication', type: :request do
6 | subject { page }
7 | let!(:user) { FactoryBot.create :user }
8 |
9 | before do
10 | RailsAdmin.config do |config|
11 | config.authenticate_with do
12 | warden.authenticate! scope: :user
13 | end
14 | config.current_user_method(&:current_user)
15 | end
16 | end
17 |
18 | it 'supports logging-in', js: true do
19 | visit dashboard_path
20 | fill_in 'Email', with: user.email
21 | fill_in 'Password', with: 'password'
22 | click_button 'Log in'
23 | is_expected.to have_css 'body.rails_admin'
24 | end
25 |
26 | it 'supports logging-out', js: true do
27 | login_as user
28 | visit dashboard_path
29 | click_link 'Log out'
30 | is_expected.to have_content 'Log in'
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/spec/rails_admin/extentions/cancancan/authorization_adapter_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Extensions::CanCanCan::AuthorizationAdapter do
6 | let(:user) { double }
7 | let(:controller) { double(_current_user: user, current_ability: MyAbility.new(user)) }
8 |
9 | class MyAbility
10 | include CanCan::Ability
11 | def initialize(_user)
12 | can :access, :rails_admin
13 | can :manage, :all
14 | end
15 | end
16 |
17 | describe '#initialize' do
18 | it 'accepts the ability class as an argument' do
19 | expect(described_class.new(controller, MyAbility).ability_class).to eq MyAbility
20 | end
21 |
22 | it 'supports block DSL' do
23 | adapter = described_class.new(controller) do
24 | ability_class MyAbility
25 | end
26 | expect(adapter.ability_class).to eq MyAbility
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/uuid_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::Uuid do
6 | let(:uuid) { SecureRandom.uuid }
7 | let(:object) { FactoryBot.create(:field_test) }
8 | let(:field) { RailsAdmin.config(FieldTest).fields.detect { |f| f.name == :uuid_field } }
9 |
10 | before do
11 | RailsAdmin.config do |config|
12 | config.model FieldTest do
13 | field :uuid_field, :uuid
14 | end
15 | end
16 |
17 | allow(object).to receive(:uuid_field).and_return uuid
18 | field.bindings = {object: object}
19 | end
20 |
21 | it 'field is a Uuid fieldtype' do
22 | expect(field.class).to eq RailsAdmin::Config::Fields::Types::Uuid
23 | end
24 |
25 | it 'handles uuid string' do
26 | expect(field.value).to eq uuid
27 | end
28 |
29 | it_behaves_like 'a generic field type', :string_field, :uuid
30 | end
31 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/sections/list_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Sections::List do
6 | describe '#fields_for_table' do
7 | subject { RailsAdmin.config(Player).list }
8 |
9 | it 'brings sticky fields first' do
10 | RailsAdmin.config Player do
11 | list do
12 | field(:number)
13 | field(:id)
14 | field(:name) { sticky true }
15 | end
16 | end
17 | expect(subject.fields_for_table.map(&:name)).to eq %i[name number id]
18 | end
19 |
20 | it 'keep the original order except for stickey ones' do
21 | RailsAdmin.config Player do
22 | list do
23 | configure(:number) { sticky true }
24 | end
25 | end
26 | expect(subject.fields_for_table.map(&:name)).to eq %i[number] + (subject.visible_fields.map(&:name) - %i[number])
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/lib/rails_admin/adapters/mongoid/object_extension.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | module Adapters
5 | module Mongoid
6 | module ObjectExtension
7 | def self.extended(object)
8 | object.associations.each do |name, association|
9 | association = Association.new(association, object.class)
10 | case association.macro
11 | when :has_many
12 | unless association.autosave?
13 | object.singleton_class.after_create do
14 | send(name).each(&:save)
15 | end
16 | end
17 | when :has_one
18 | unless association.autosave?
19 | object.singleton_class.after_create do
20 | send(name)&.save
21 | end
22 | end
23 | end
24 | end
25 | end
26 | end
27 | end
28 | end
29 | end
30 |
--------------------------------------------------------------------------------
/.github/workflows/code-ql.yml:
--------------------------------------------------------------------------------
1 | name: "CodeQL"
2 |
3 | on:
4 | push:
5 | branches: [master]
6 | pull_request:
7 | # The branches below must be a subset of the branches above
8 | branches: [master]
9 | schedule:
10 | - cron: "12 00 * * 5"
11 |
12 | jobs:
13 | analyze:
14 | name: Analyze
15 | runs-on: ubuntu-latest
16 | permissions:
17 | actions: read
18 | contents: read
19 | security-events: write
20 |
21 | strategy:
22 | fail-fast: false
23 | matrix:
24 | language: ["ruby"]
25 |
26 | steps:
27 | - name: Checkout repository
28 | uses: actions/checkout@v3
29 |
30 | # Initializes the CodeQL tools for scanning.
31 | - name: Initialize CodeQL
32 | uses: github/codeql-action/init@v2
33 | with:
34 | languages: ${{ matrix.language }}
35 |
36 | - name: Perform CodeQL Analysis
37 | uses: github/codeql-action/analyze@v2
38 |
--------------------------------------------------------------------------------
/spec/rails_admin/config/fields/types/string_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe RailsAdmin::Config::Fields::Types::String do
6 | describe '#html_attributes' do
7 | before :each do
8 | RailsAdmin.config Ball do
9 | field 'color', :string
10 | end
11 | end
12 |
13 | let(:string_field) do
14 | RailsAdmin.config('Ball').fields.detect do |f|
15 | f.name == :color
16 | end.with(object: Ball.new)
17 | end
18 |
19 | it 'should contain a size attribute' do
20 | expect(string_field.html_attributes[:size]).to be_present
21 | end
22 |
23 | it 'should not contain a size attribute valorized with 0' do
24 | expect(string_field.html_attributes[:size]).to_not be_zero
25 | end
26 | end
27 |
28 | it_behaves_like 'a generic field type', :string_field
29 |
30 | it_behaves_like 'a string-like field type', :string_field
31 | end
32 |
--------------------------------------------------------------------------------
/app/views/rails_admin/main/_form_boolean.html.erb:
--------------------------------------------------------------------------------
1 | <% if field.nullable? %>
2 |
3 | <% {'1': [true, 'btn-outline-success'], '0': [false, 'btn-outline-danger'], '': [nil, 'btn-outline-secondary']}.each do |text, (value, btn_class)| %>
4 | <%= form.radio_button field.method_name, text, field.html_attributes.reverse_merge({ checked: field.form_value == value, required: field.required, class: 'btn-check' }) %>
5 | <%= form.label "#{field.method_name}_#{text}", class: "#{field.css_classes[value]} btn #{btn_class}" do %>
6 | <%= field.labels[value].html_safe %>
7 | <% end %>
8 | <% end %>
9 |
10 | <% else %>
11 |
12 | <%= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, checked: field.form_value.in?([true, '1']), required: field.required, class: 'form-check-input' }) %>
13 |
14 | <% end %>
15 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/rails_admin/application.scss.erb:
--------------------------------------------------------------------------------
1 | @charset "UTF-8";
2 |
3 | /*** Variables ***/
4 |
5 | @import "rails_admin/custom/variables";
6 | @import "rails_admin/styles/base/variables";
7 |
8 | /*** Mixins ***/
9 |
10 | @import "rails_admin/styles/base/mixins";
11 | @import "rails_admin/custom/mixins";
12 |
13 | /*** Bootstrap ***/
14 |
15 | @import "rails_admin/bootstrap/bootstrap";
16 |
17 | /*** Libraries ***/
18 |
19 | @import "rails_admin/flatpickr";
20 | @import "rails_admin/styles/filtering-select";
21 | @import "rails_admin/styles/filtering-multiselect";
22 | @import "rails_admin/styles/widgets";
23 |
24 | /*** Font-awesome ***/
25 |
26 | @import "rails_admin/font-awesome";
27 |
28 | /*** RailsAdmin Theming ***/
29 |
30 | @import "rails_admin/styles/base/theming";
31 | @import "rails_admin/custom/theming";
32 |
33 | <% if defined?(ActionText::Engine) && Rails.gem_version >= Gem::Version.new('7.0') %>
34 | @import "trix";
35 | <% end %>
36 |
--------------------------------------------------------------------------------
/spec/integration/fields/floara_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'Floara field', type: :request do
6 | subject { page }
7 |
8 | it 'works without error', js: true do
9 | RailsAdmin.config Draft do
10 | edit do
11 | field :notes, :froala
12 | end
13 | end
14 | expect { visit new_path(model_name: 'draft') }.not_to raise_error
15 | is_expected.to have_selector('.fr-box')
16 | end
17 |
18 | it 'should include custom froala configuration' do
19 | RailsAdmin.config Draft do
20 | edit do
21 | field :notes, :froala do
22 | config_options inlineMode: false
23 | css_location 'stub_css.css'
24 | js_location 'stub_js.js'
25 | end
26 | end
27 | end
28 |
29 | visit new_path(model_name: 'draft')
30 | is_expected.to have_selector('textarea#draft_notes[data-richtext="froala-wysiwyg"][data-options]')
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/src/rails_admin/abstract-select.js:
--------------------------------------------------------------------------------
1 | import jQuery from "jquery";
2 | import "jquery-ui/ui/widget.js";
3 |
4 | (function ($) {
5 | "use strict";
6 |
7 | $.widget("ra.abstractSelect", {
8 | options: {
9 | createQuery: function (query) {
10 | if ($.isEmptyObject(this.scopeBy)) {
11 | return { query: query };
12 | } else {
13 | const filterQuery = {};
14 | for (var field in this.scopeBy) {
15 | const targetField = this.scopeBy[field];
16 | const targetValue = $(`[name$="[${field}]"]`).val();
17 | if (!filterQuery[targetField]) {
18 | filterQuery[targetField] = [];
19 | }
20 | filterQuery[targetField].push(
21 | targetValue ? { o: "is", v: targetValue } : { o: "_blank" }
22 | );
23 | }
24 | return { query: query, f: filterQuery };
25 | }
26 | },
27 | scopeBy: {},
28 | },
29 | });
30 | })(jQuery);
31 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "rails_admin",
3 | "version": "3.3.0",
4 | "description": "RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data.",
5 | "homepage": "https://github.com/railsadminteam/rails_admin",
6 | "license": "MIT",
7 | "author": "Mitsuhiro Shibuya ",
8 | "files": [
9 | "src"
10 | ],
11 | "main": "src/rails_admin/base.js",
12 | "scripts": {
13 | "link": "yarn link && cd spec/dummy_app && yarn link rails_admin",
14 | "format": "prettier -w ."
15 | },
16 | "dependencies": {
17 | "@babel/runtime": "^7.16.7",
18 | "@fortawesome/fontawesome-free": ">=5.15.0 <7.0.0",
19 | "@hotwired/turbo-rails": "^7.1.0",
20 | "@popperjs/core": "^2.11.0",
21 | "@rails/ujs": "^6.1.4-1",
22 | "bootstrap": "^5.1.3",
23 | "flatpickr": "^4.6.9",
24 | "jquery": "^3.6.0",
25 | "jquery-ui": "^1.12.1 <1.14.0"
26 | },
27 | "devDependencies": {
28 | "prettier": "^2.4.1"
29 | }
30 | }
31 |
--------------------------------------------------------------------------------
/spec/dummy_app/public/422.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The change you wanted was rejected (422)
5 |
26 |
27 |
28 |
29 |
30 |
31 |
The change you wanted was rejected.
32 |
Maybe you tried to change something you didn't have access to.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/spec/integration/fields/wysihtml5_spec.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'spec_helper'
4 |
5 | RSpec.describe 'Wysihtml5 field', type: :request do
6 | subject { page }
7 |
8 | it 'works without error', js: true do
9 | RailsAdmin.config Draft do
10 | edit do
11 | field :notes, :wysihtml5
12 | end
13 | end
14 | expect { visit new_path(model_name: 'draft') }.not_to raise_error
15 | is_expected.to have_selector('.wysihtml5-toolbar')
16 | end
17 |
18 | it 'should include custom wysihtml5 configuration' do
19 | RailsAdmin.config Draft do
20 | edit do
21 | field :notes, :wysihtml5 do
22 | config_options image: false
23 | css_location 'stub_css.css'
24 | js_location 'stub_js.js'
25 | end
26 | end
27 | end
28 |
29 | visit new_path(model_name: 'draft')
30 | is_expected.to have_selector('textarea#draft_notes[data-richtext="bootstrap-wysihtml5"][data-options]')
31 | end
32 | end
33 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/fields/factories/enum.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields'
4 | require 'rails_admin/config/fields/types/enum'
5 | require 'rails_admin/config/fields/types/active_record_enum'
6 |
7 | RailsAdmin::Config::Fields.register_factory do |parent, properties, fields|
8 | model = parent.abstract_model.model
9 | method_name = "#{properties.name}_enum"
10 |
11 | # NOTICE: _method_name could be `to_enum` and this method defined in Object.
12 | if !Object.respond_to?(method_name) && \
13 | (model.respond_to?(method_name) || \
14 | model.method_defined?(method_name))
15 | fields << RailsAdmin::Config::Fields::Types::Enum.new(parent, properties.name, properties)
16 | true
17 | elsif model.respond_to?(:defined_enums) && model.defined_enums[properties.name.to_s]
18 | fields << RailsAdmin::Config::Fields::Types::ActiveRecordEnum.new(parent, properties.name, properties)
19 | true
20 | else
21 | false
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/actions/show.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | module Config
5 | module Actions
6 | class Show < RailsAdmin::Config::Actions::Base
7 | RailsAdmin::Config::Actions.register(self)
8 |
9 | register_instance_option :member do
10 | true
11 | end
12 |
13 | register_instance_option :route_fragment do
14 | ''
15 | end
16 |
17 | register_instance_option :breadcrumb_parent do
18 | [:index, bindings[:abstract_model]]
19 | end
20 |
21 | register_instance_option :controller do
22 | proc do
23 | respond_to do |format|
24 | format.json { render json: @object }
25 | format.html { render @action.template_name }
26 | end
27 | end
28 | end
29 |
30 | register_instance_option :link_icon do
31 | 'fas fa-info-circle'
32 | end
33 | end
34 | end
35 | end
36 | end
37 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/actions/show_in_app.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | module RailsAdmin
4 | module Config
5 | module Actions
6 | class ShowInApp < RailsAdmin::Config::Actions::Base
7 | RailsAdmin::Config::Actions.register(self)
8 |
9 | register_instance_option :member do
10 | true
11 | end
12 |
13 | register_instance_option :visible? do
14 | authorized? && begin
15 | bindings[:controller].main_app.url_for(bindings[:object])
16 | rescue StandardError
17 | false
18 | end
19 | end
20 |
21 | register_instance_option :controller do
22 | proc do
23 | redirect_to main_app.url_for(@object)
24 | end
25 | end
26 |
27 | register_instance_option :link_icon do
28 | 'fas fa-eye'
29 | end
30 |
31 | register_instance_option :turbo? do
32 | false
33 | end
34 | end
35 | end
36 | end
37 | end
38 |
--------------------------------------------------------------------------------
/spec/dummy_app/public/404.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | The page you were looking for doesn't exist (404)
5 |
26 |
27 |
28 |
29 |
30 |
31 |
The page you were looking for doesn't exist.
32 |
You may have mistyped the address or the page may have moved.
33 |
34 |
35 |
36 |
--------------------------------------------------------------------------------
/spec/dummy_app/.dockerignore:
--------------------------------------------------------------------------------
1 | # See https://docs.docker.com/engine/reference/builder/#dockerignore-file for more about ignoring files.
2 |
3 | # Ignore git directory.
4 | /.git/
5 |
6 | # Ignore bundler config and Gemfile.lock.
7 | /.bundle
8 | /Gemfile.lock
9 |
10 | # Ignore all default key files.
11 | /config/master.key
12 | /config/credentials/*.key
13 |
14 | # Ignore all environment files.
15 | /.env*
16 | !/.env.example
17 |
18 | # Ignore all logfiles and tempfiles.
19 | /log/*
20 | /tmp/*
21 | !/log/.keep
22 | !/tmp/.keep
23 |
24 | # Ignore pidfiles, but keep the directory.
25 | /tmp/pids/*
26 | !/tmp/pids/
27 | !/tmp/pids/.keep
28 |
29 | # Ignore storage (uploaded files in development and any SQLite databases).
30 | /db/*.sqlite3
31 | /public/system
32 | /public/uploads
33 | /public/vite
34 | /storage/*
35 | !/storage/.keep
36 | /tmp/storage/*
37 | !/tmp/storage/
38 | !/tmp/storage/.keep
39 |
40 | # Ignore assets.
41 | /node_modules/
42 | /app/assets/builds/*
43 | !/app/assets/builds/.keep
44 | /public/assets
45 |
--------------------------------------------------------------------------------
/spec/dummy_app/app/active_record/player.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class Player < ActiveRecord::Base
4 | belongs_to :team, optional: true, inverse_of: :players
5 | has_one :draft, dependent: :destroy
6 | has_many :comments, as: :commentable
7 |
8 | validates_presence_of(:name)
9 | validates_numericality_of(:number, only_integer: true)
10 | validates_uniqueness_of(:number, scope: :team_id, message: 'There is already a player with that number on this team')
11 | validates_each :name do |record, _attr, value|
12 | record.errors.add(:base, 'Player is cheating') if /on steroids/.match?(value.to_s)
13 | end
14 |
15 | if ActiveRecord.gem_version >= Gem::Version.new('7.0')
16 | enum :formation, {start: 'start', substitute: 'substitute'}
17 | else
18 | enum formation: {start: 'start', substitute: 'substitute'}
19 | end
20 |
21 | before_destroy :destroy_hook
22 |
23 | scope :rails_admin_search, ->(query) { where(name: query.reverse) }
24 |
25 | def destroy_hook; end
26 | end
27 |
--------------------------------------------------------------------------------
/lib/rails_admin/config/has_groups.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | require 'rails_admin/config/fields/group'
4 |
5 | module RailsAdmin
6 | module Config
7 | module HasGroups
8 | # Accessor for a group
9 | #
10 | # If group with given name does not yet exist it will be created. If a
11 | # block is passed it will be evaluated in the context of the group
12 | def group(name, &block)
13 | group = parent.groups.detect { |g| name == g.name }
14 | group ||= (parent.groups << RailsAdmin::Config::Fields::Group.new(self, name)).last
15 | group.tap { |g| g.section = self }.instance_eval(&block) if block
16 | group
17 | end
18 |
19 | # Reader for groups that are marked as visible
20 | def visible_groups
21 | parent.groups.collect { |f| f.section = self; f.with(bindings) }.select(&:visible?).select do |g| # rubocop:disable Style/Semicolon
22 | g.visible_fields.present?
23 | end
24 | end
25 | end
26 | end
27 | end
28 |
--------------------------------------------------------------------------------