├── 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 |

<%= @player.name %>

2 | <%= link_to 'Back to admin', rails_admin.show_path(model_name: 'player', id: @player.id) %> -------------------------------------------------------------------------------- /spec/support/fixtures.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | def file_path(*paths) 4 | File.expand_path(File.join(File.dirname(__FILE__), '../fixtures', *paths)) 5 | end 6 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_text-truncation.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Text truncation 3 | // 4 | 5 | .text-truncate { 6 | @include text-truncate(); 7 | } 8 | -------------------------------------------------------------------------------- /lib/generators/rails_admin/templates/rails_admin.scss.erb: -------------------------------------------------------------------------------- 1 | <%= @fa_font_path ? %{$fa-font-path: "#{@fa_font_path}";\n} : '' %>@import "rails_admin/src/rails_admin/styles/base"; 2 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/read_only_comment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ReadOnlyComment < Comment 4 | def readonly? 5 | true 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /src/rails_admin/styles/base/README.txt: -------------------------------------------------------------------------------- 1 | For RailsAdmin developers: 2 | We should use sass variables & mixins as much as possible so that themers/users can override them cleanly 3 | -------------------------------------------------------------------------------- /spec/dummy_app/app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationController < ActionController::Base 4 | protect_from_forgery 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | APP_PATH = File.expand_path('../../config/application', __FILE__) 3 | require_relative '../config/boot' 4 | require 'rails/commands' 5 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/_gap.html.erb: -------------------------------------------------------------------------------- 1 |
  • 2 | 3 | <%= raw(t 'admin.pagination.truncate') %> 4 | 5 |
  • 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/embed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Embed 4 | include Mongoid::Document 5 | field :name, type: String 6 | 7 | embedded_in :field_test 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy_app/vite.config.ts: -------------------------------------------------------------------------------- 1 | import { defineConfig } from "vite"; 2 | import RubyPlugin from "vite-plugin-ruby"; 3 | 4 | export default defineConfig({ 5 | plugins: [RubyPlugin()], 6 | }); 7 | -------------------------------------------------------------------------------- /lib/rails_admin/extensions/controller_extension.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Extensions 5 | module ControllerExtension 6 | end 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/category.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Category 4 | include Mongoid::Document 5 | 6 | belongs_to :parent_category, class_name: 'Category' 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg.meta: -------------------------------------------------------------------------------- 1 | {: nameI"Pensive Parakeet.jpg:ET:model_classI"FieldTest;F:model_attachment:dragonfly_asset -------------------------------------------------------------------------------- /spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg.meta: -------------------------------------------------------------------------------- 1 | {: nameI"Costa Rican Frog.jpg:ET:model_classI"FieldTest;F:model_attachment:dragonfly_asset -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/category.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Category < ActiveRecord::Base 4 | belongs_to :parent_category, class_name: 'Category', optional: true 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/restricted_team.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class RestrictedTeam < Team 4 | has_many :players, foreign_key: :team_id, dependent: :restrict_with_error 5 | end 6 | -------------------------------------------------------------------------------- /spec/support/cuprite_logger.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ConsoleLogger 4 | def self.puts(message) 5 | warn(message) unless message.start_with?(' ◀', "\n\n▶") 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/restricted_team.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class RestrictedTeam < Team 4 | has_many :players, foreign_key: :team_id, dependent: :restrict_with_error 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/jobs/null_job.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class NullJob < ApplicationJob 4 | queue_as :default 5 | 6 | def perform(*args) 7 | # Do nothing 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/comment/confirmed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Comment 4 | class Confirmed < Comment 5 | default_scope -> { where(content: 'something') } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/1/thumb/Boston City Flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/1/thumb/Boston City Flow.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/3/thumb/Costa Rican Frog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/3/thumb/Costa Rican Frog.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/6/thumb/liste-electorale.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/6/thumb/liste-electorale.pdf -------------------------------------------------------------------------------- /.prettierignore: -------------------------------------------------------------------------------- 1 | coverage 2 | lib/generators/rails_admin/templates 3 | spec/dummy_app/app/assets/builds 4 | spec/dummy_app/public 5 | spec/dummy_app/tmp 6 | spec/support/jquery.simulate.drag-sortable.js 7 | vendor 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/another_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AnotherFieldTest < ActiveRecord::Base 4 | has_many :nested_field_tests, inverse_of: :another_field_test 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/comment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Comment < ActiveRecord::Base 4 | include Taggable 5 | belongs_to :commentable, polymorphic: true, optional: true 6 | end 7 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/comment/confirmed.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Comment 4 | class Confirmed < Comment 5 | default_scope { where(content: 'something') } 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/paper_trail_test/subclass_in_namespace.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class PaperTrailTest < ActiveRecord::Base 4 | class SubclassInNamespace < self 5 | end 6 | end 7 | -------------------------------------------------------------------------------- /spec/dummy_app/config/webpack/test.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "development"; 2 | 3 | const environment = require("./environment"); 4 | 5 | module.exports = environment.toWebpackConfig(); 6 | -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/1/original/Boston City Flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/1/original/Boston City Flow.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/3/original/Costa Rican Frog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/3/original/Costa Rican Frog.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/system/paperclip_assets/6/original/liste-electorale.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/paperclip_assets/6/original/liste-electorale.pdf -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_field.html.erb: -------------------------------------------------------------------------------- 1 | <%= form.send field.view_helper, field.method_name, field.html_attributes.reverse_merge({ value: field.form_value, class: 'form-control', required: field.required}) %> 2 | -------------------------------------------------------------------------------- /spec/dummy_app/app/controllers/players_controller.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class PlayersController < ApplicationController 4 | def show 5 | @player = Player.find(params[:id]) 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/bin/dev: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | if ! command -v foreman &> /dev/null 4 | then 5 | echo "Installing foreman..." 6 | gem install foreman 7 | fi 8 | 9 | foreman start -f Procfile.dev "$@" 10 | -------------------------------------------------------------------------------- /spec/dummy_app/config/webpack/development.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "development"; 2 | 3 | const environment = require("./environment"); 4 | 5 | module.exports = environment.toWebpackConfig(); 6 | -------------------------------------------------------------------------------- /spec/dummy_app/config/webpack/production.js: -------------------------------------------------------------------------------- 1 | process.env.NODE_ENV = process.env.NODE_ENV || "production"; 2 | 3 | const environment = require("./environment"); 4 | 5 | module.exports = environment.toWebpackConfig(); 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/another_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AnotherFieldTest 4 | include Mongoid::Document 5 | 6 | has_many :nested_field_tests, inverse_of: :another_field_test 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/Boston_City_Flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/Boston_City_Flow.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/Costa_Rican_Frog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/Costa_Rican_Frog.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/Pensive_Parakeet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/Pensive_Parakeet.jpg -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/managed_team.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ManagedTeam < Team 4 | belongs_to :user, class_name: 'ManagingUser', foreign_key: :manager, primary_key: :email, inverse_of: :teams 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/config.ru: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # This file is used by Rack-based servers to start the application. 4 | 5 | require ::File.expand_path('config/environment', __dir__) 6 | run DummyApp::Application 7 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20111115041025_add_type_to_balls.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddTypeToBalls < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :balls, :type, :string 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /lib/rails_admin/extensions/pundit.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/extensions/pundit/authorization_adapter' 4 | 5 | RailsAdmin.add_extension(:pundit, RailsAdmin::Extensions::Pundit, authorization: true) 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/deeply_nested_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeeplyNestedFieldTest < ActiveRecord::Base 4 | belongs_to :nested_field_test, inverse_of: :deeply_nested_field_tests 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/thumb_Boston_City_Flow.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/3/thumb_Boston_City_Flow.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/thumb_Costa_Rican_Frog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/4/thumb_Costa_Rican_Frog.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/thumb_Pensive_Parakeet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/uploads/field_test/carrierwave_asset/6/thumb_Pensive_Parakeet.jpg -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/session_store.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | Rails.application.config.session_store :cookie_store, key: '_dummy_app_session' 6 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_vr.scss: -------------------------------------------------------------------------------- 1 | .vr { 2 | display: inline-block; 3 | align-self: stretch; 4 | width: 1px; 5 | min-height: 1em; 6 | background-color: currentColor; 7 | opacity: $hr-opacity; 8 | } 9 | -------------------------------------------------------------------------------- /lib/rails_admin/extensions/paper_trail.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/extensions/paper_trail/auditing_adapter' 4 | 5 | RailsAdmin.add_extension(:paper_trail, RailsAdmin::Extensions::PaperTrail, auditing: true) 6 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/image.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Image < ActiveRecord::Base 4 | has_attached_file :file, styles: {medium: '300x300>', thumb: '100x100>'} 5 | validates_attachment_presence :file 6 | end 7 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/two_level/namespaced.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module TwoLevel 4 | module Namespaced 5 | def self.table_name_prefix 6 | 'two_level_namespaced_' 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/config/environment.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Load the Rails application. 4 | require File.expand_path('application', __dir__) 5 | 6 | # Initialize the Rails application. 7 | DummyApp::Application.initialize! 8 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20211011235734_add_bool_field_open.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddBoolFieldOpen < ActiveRecord::Migration[6.0] 4 | def change 5 | add_column :field_tests, :open, :boolean 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_visually-hidden.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Visually hidden 3 | // 4 | 5 | .visually-hidden, 6 | .visually-hidden-focusable:not(:focus):not(:focus-within) { 7 | @include visually-hidden(); 8 | } 9 | -------------------------------------------------------------------------------- /app/views/layouts/rails_admin/_sidebar_navigation.html.erb: -------------------------------------------------------------------------------- 1 | 6 | -------------------------------------------------------------------------------- /config/initializers/mongoid_extensions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | if defined?(::Mongoid::Document) 4 | require 'rails_admin/adapters/mongoid/extension' 5 | Mongoid::Document.include RailsAdmin::Adapters::Mongoid::Extension 6 | end 7 | -------------------------------------------------------------------------------- /lib/rails_admin/extensions/cancancan.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/extensions/cancancan/authorization_adapter' 4 | 5 | RailsAdmin.add_extension(:cancancan, RailsAdmin::Extensions::CanCanCan, authorization: true) 6 | -------------------------------------------------------------------------------- /spec/dummy_app/doc/README_FOR_APP: -------------------------------------------------------------------------------- 1 | Use this README file to introduce your application and point to useful places in the API for learning more. 2 | Run "rake doc:app" to generate API documentation for your models, controllers, helpers, and libraries. 3 | -------------------------------------------------------------------------------- /spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/dragonfly/development/2011/11/24/10_36_27_888_Pensive_Parakeet.jpg -------------------------------------------------------------------------------- /spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/railsadminteam/rails_admin/HEAD/spec/dummy_app/public/system/dragonfly/development/2011/11/30/08_54_39_906_Costa_Rican_Frog.jpg -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/float_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Float do 6 | it_behaves_like 'a float-like field type', :float_field 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/managed_team.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ManagedTeam < Team 4 | belongs_to :user, class_name: 'ManagingUser', foreign_key: :manager, primary_key: :email, optional: true, inverse_of: :teams 5 | end 6 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20120117151733_add_custom_field_to_teams.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddCustomFieldToTeams < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :teams, :custom_field, :string 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/wc/norobots.html for documentation on how to use the robots.txt file 2 | # 3 | # To ban all spiders from the entire site uncomment the next two lines: 4 | # User-Agent: * 5 | # Disallow: / 6 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/decimal_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Decimal do 6 | it_behaves_like 'a float-like field type', :float_field 7 | end 8 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/inet_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Inet do 6 | it_behaves_like 'a generic field type', :string_field, :inet 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # Add new mime types for use in respond_to blocks: 6 | # Mime::Type.register "text/richtext", :rtf 7 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_clearfix.scss: -------------------------------------------------------------------------------- 1 | // scss-docs-start clearfix 2 | @mixin clearfix() { 3 | &::after { 4 | display: block; 5 | clear: both; 6 | content: ""; 7 | } 8 | } 9 | // scss-docs-end clearfix 10 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_lists.scss: -------------------------------------------------------------------------------- 1 | // Lists 2 | 3 | // Unstyled keeps list items block level, just removes default browser padding and list-style 4 | @mixin list-unstyled { 5 | padding-left: 0; 6 | list-style: none; 7 | } 8 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_text.html.erb: -------------------------------------------------------------------------------- 1 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: false, options: {}.to_json }).reverse_merge({ value: field.form_value, class: 'form-control', required: field.required }) %> 2 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/integer_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Integer do 6 | it_behaves_like 'a generic field type', :integer_field, :integer 7 | end 8 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_color-scheme.scss: -------------------------------------------------------------------------------- 1 | // scss-docs-start mixin-color-scheme 2 | @mixin color-scheme($name) { 3 | @media (prefers-color-scheme: #{$name}) { 4 | @content; 5 | } 6 | } 7 | // scss-docs-end mixin-color-scheme 8 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/shrine.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'shrine' 4 | require 'shrine/storage/memory' 5 | 6 | Shrine.storages = { 7 | cache: Shrine::Storage::Memory.new, 8 | store: Shrine::Storage::Memory.new, 9 | } 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/serialized_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Serialized do 6 | it_behaves_like 'a generic field type', :text_field, :serialized 7 | end 8 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_colorpicker.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 | 8 | <% end %> 9 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/nested_favorite_player.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | if ActiveRecord.gem_version >= Gem::Version.new('7.1') || defined?(CompositePrimaryKeys) 4 | class NestedFavoritePlayer < FavoritePlayer 5 | accepts_nested_attributes_for :fanship 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/shrine_uploader.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ShrineUploader < Shrine 4 | plugin :activerecord 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/app/mongoid/image.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Image 4 | include Mongoid::Document 5 | include Mongoid::Paperclip 6 | 7 | has_mongoid_attached_file :file, styles: {medium: '300x300>', thumb: '100x100>'} 8 | validates_attachment_presence :file 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/lib/does_not_load_autoload_paths_not_in_eager_load.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module DoesNotLoadAutoloadPathsNotInEagerLoad 4 | raise 'This file is in app.paths.autoload but not app.paths.eager_load and ' \ 5 | ' should not be autoloaded by rails_admin' 6 | end 7 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/edit.html.erb: -------------------------------------------------------------------------------- 1 | <%= rails_admin_form_for @object, url: edit_path(@abstract_model, @object.id), as: @abstract_model.param_key, html: { method: "put", multipart: true, class: "main", data: { title: @page_name } } do |form| %> 2 | <%= form.generate action: :update %> 3 | <% end %> 4 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/modal.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/edit' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | class Modal < RailsAdmin::Config::Sections::Edit 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/show.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/base' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | class Show < RailsAdmin::Config::Sections::Base 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # Configure sensitive parameters which will be filtered from the log file. 6 | Rails.application.config.filter_parameters += [:password] 7 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20111215083258_create_foo_bars.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateFooBars < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :foo_bars do |t| 6 | t.string :title 7 | t.timestamps null: false 8 | end 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/belongs_to_association_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::BelongsToAssociation do 6 | it_behaves_like 'a generic field type', :integer_field, :belongs_to_association 7 | end 8 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if page.current? %> 2 |
  • 3 | <%= link_to page, url, class: 'page-link' %> 4 |
  • 5 | <% else %> 6 |
  • 7 | <%= link_to page, url, class: 'page-link' %> 8 |
  • 9 | <% end %> 10 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/nested.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/edit' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | class Nested < RailsAdmin::Config::Sections::Edit 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/update.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/edit' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | class Update < RailsAdmin::Config::Sections::Edit 9 | end 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/two_level/namespaced/polymorphic_association_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module TwoLevel 4 | module Namespaced 5 | class PolymorphicAssociationTest < ActiveRecord::Base 6 | has_many :comments, as: :commentable 7 | end 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20151027181550_change_field_test_id_to_nested_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ChangeFieldTestIdToNestedFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | change_column :nested_field_tests, :field_test_id, :integer, null: false 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20180707101855_add_carrierwave_assets_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddCarrierwaveAssetsToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :carrierwave_assets, :string, after: :carrierwave_asset 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20240921171953_add_non_nullable_boolean_field.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddNonNullableBooleanField < ActiveRecord::Migration[6.0] 4 | def change 5 | add_column :field_tests, :non_nullable_boolean_field, :boolean, null: false, default: false 6 | end 7 | end 8 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/ball.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Ball < ActiveRecord::Base 4 | has_one :comment, as: :commentable 5 | 6 | validates_presence_of :color, on: :create 7 | 8 | def to_param 9 | color.present? ? color.downcase.tr(' ', '-') : id 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/nested_fan.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | if ActiveRecord.gem_version >= Gem::Version.new('7.1') || defined?(CompositePrimaryKeys) 4 | class NestedFan < Fan 5 | accepts_nested_attributes_for :fanships 6 | accepts_nested_attributes_for :fanship 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/deeply_nested_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DeeplyNestedFieldTest 4 | include Mongoid::Document 5 | include Mongoid::Timestamps 6 | 7 | field :title, type: String 8 | belongs_to :nested_field_test, inverse_of: :deeply_nested_field_tests 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000013_add_roles_to_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddRolesToUser < ActiveRecord::Migration[5.0] 4 | def self.up 5 | add_column :users, :roles, :string 6 | end 7 | 8 | def self.down 9 | remove_column :users, :roles 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/postcss.config.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | plugins: [ 3 | require("postcss-import"), 4 | require("postcss-flexbugs-fixes"), 5 | require("postcss-preset-env")({ 6 | autoprefixer: { 7 | flexbox: "no-2009", 8 | }, 9 | stage: 3, 10 | }), 11 | ], 12 | }; 13 | -------------------------------------------------------------------------------- /app/views/layouts/rails_admin/modal.js.erb: -------------------------------------------------------------------------------- 1 | <% flash && flash.each do |key, value| %> 2 |
    3 | <%= value %> 4 | 5 |
    6 | <% end %> 7 | <%= yield %> 8 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/text_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Text do 6 | it_behaves_like 'a generic field type', :text_field 7 | 8 | it_behaves_like 'a string-like field type', :text_field 9 | end 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/citext_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Citext do 6 | it_behaves_like 'a generic field type', :string_field 7 | 8 | it_behaves_like 'a string-like field type', :string_field 9 | end 10 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_action_text.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | csspath: field.css_location, 4 | jspath: field.js_location, 5 | warn_dynamic_load: field.warn_dynamic_load 6 | } 7 | %> 8 | <%= form.rich_text_area field.method_name, field.html_attributes.reverse_merge(data: { options: js_data.to_json }) %> 9 | -------------------------------------------------------------------------------- /spec/dummy_app/Rakefile: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Add your own tasks in files placed in lib/tasks ending in .rake, 4 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 5 | 6 | require File.expand_path('config/application', __dir__) 7 | 8 | DummyApp::Application.load_tasks 9 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000014_add_color_to_team_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddColorToTeamMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | add_column :teams, :color, :string 6 | end 7 | 8 | def self.down 9 | remove_column :teams, :color 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/config/routes.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | DummyApp::Application.routes.draw do 4 | # Needed for :show_in_app tests 5 | resources :players, only: [:show] 6 | 7 | devise_for :users 8 | mount RailsAdmin::Engine => '/admin', as: 'rails_admin' 9 | root to: 'rails_admin/main#dashboard' 10 | end 11 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20140826093220_create_paper_trail_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreatePaperTrailTests < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :paper_trail_tests do |t| 6 | t.string :name 7 | 8 | t.timestamps null: false 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20171229220713_add_enum_fields_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddEnumFieldsToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :string_enum_field, :string 6 | add_column :field_tests, :integer_enum_field, :integer 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/managing_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ManagingUser < User 4 | has_one :team, class_name: 'ManagedTeam', foreign_key: :manager, primary_key: :email, inverse_of: :user 5 | has_many :teams, class_name: 'ManagedTeam', foreign_key: :manager, primary_key: :email, inverse_of: :user 6 | end 7 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/mongoid.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | if CI_ORM == :mongoid 4 | filename = 5 | if Mongoid.respond_to?(:belongs_to_required_by_default=) 6 | 'mongoid6.yml' 7 | else 8 | 'mongoid5.yml' 9 | end 10 | ::Mongoid.load!(Rails.root.join('config', filename)) 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110329183136_remove_league_id_from_teams.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class RemoveLeagueIdFromTeams < ActiveRecord::Migration[5.0] 4 | def self.up 5 | remove_column :teams, :league_id 6 | end 7 | 8 | def self.down 9 | add_column :teams, :league_id, :integer 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110607152842_add_format_to_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddFormatToFieldTest < ActiveRecord::Migration[5.0] 4 | def self.up 5 | add_column :field_tests, :format, :string 6 | end 7 | 8 | def self.down 9 | remove_column :field_tests, :format 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20181029101829_add_shrine_data_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddShrineDataToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :shrine_asset_data, :text 6 | add_column :field_tests, :shrine_versioning_asset_data, :text 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/color_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Color do 6 | it_behaves_like 'a generic field type', :string_field, :color 7 | 8 | it_behaves_like 'a string-like field type', :string_field, :color 9 | end 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/froala_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Froala do 6 | it_behaves_like 'a generic field type', :text_field, :froala 7 | 8 | it_behaves_like 'a string-like field type', :text_field, :froala 9 | end 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/has_and_belongs_to_many_association_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::HasAndBelongsToManyAssociation do 6 | it_behaves_like 'a generic field type', :integer_field, :has_and_belongs_to_many_association 7 | end 8 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/forms/_form-text.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Form text 3 | // 4 | 5 | .form-text { 6 | margin-top: $form-text-margin-top; 7 | @include font-size($form-text-font-size); 8 | font-style: $form-text-font-style; 9 | font-weight: $form-text-font-weight; 10 | color: $form-text-color; 11 | } 12 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/cms/basic_page.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module Cms 4 | class BasicPage 5 | include Mongoid::Document 6 | field :title, type: String 7 | field :content, type: String 8 | include Mongoid::Timestamps 9 | 10 | validates :title, :content, presence: true 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/hidden_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Hidden do 6 | it_behaves_like 'a generic field type', :integer_field, :hidden 7 | 8 | it_behaves_like 'a string-like field type', :string_field, :hidden 9 | end 10 | -------------------------------------------------------------------------------- /lib/rails_admin/adapters/active_record/object_extension.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Adapters 5 | module ActiveRecord 6 | module ObjectExtension 7 | def assign_attributes(attributes) 8 | super if attributes 9 | end 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/ck_editor_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::CKEditor do 6 | it_behaves_like 'a generic field type', :text_field, :ck_editor 7 | 8 | it_behaves_like 'a string-like field type', :text_field, :ck_editor 9 | end 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/wysihtml5_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Wysihtml5 do 6 | it_behaves_like 'a generic field type', :text_field, :wysihtml5 7 | 8 | it_behaves_like 'a string-like field type', :text_field, :wysihtml5 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/assets/javascripts/rails_admin/custom/ui.js: -------------------------------------------------------------------------------- 1 | window.domReadyTriggered = []; 2 | 3 | document.addEventListener("rails_admin.dom_ready", function () { 4 | window.domReadyTriggered.push("plainjs/dot"); 5 | }); 6 | 7 | $(document).on("rails_admin.dom_ready", function () { 8 | window.domReadyTriggered.push("jquery/dot"); 9 | }); 10 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/simple_mde_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::SimpleMDE do 6 | it_behaves_like 'a generic field type', :text_field, :simple_mde 7 | 8 | it_behaves_like 'a string-like field type', :text_field, :simple_mde 9 | end 10 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/_forms.scss: -------------------------------------------------------------------------------- 1 | @import "forms/labels"; 2 | @import "forms/form-text"; 3 | @import "forms/form-control"; 4 | @import "forms/form-select"; 5 | @import "forms/form-check"; 6 | @import "forms/form-range"; 7 | @import "forms/floating-labels"; 8 | @import "forms/input-group"; 9 | @import "forms/validation"; 10 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/export.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/base' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | # Configuration of the navigation view 9 | class Export < RailsAdmin::Config::Sections::Base 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/code_mirror_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::CodeMirror do 6 | it_behaves_like 'a generic field type', :text_field, :code_mirror 7 | 8 | it_behaves_like 'a string-like field type', :text_field, :code_mirror 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/config/vite.json: -------------------------------------------------------------------------------- 1 | { 2 | "all": { 3 | "sourceCodeDir": "app/frontend", 4 | "watchAdditionalPaths": ["../../src"] 5 | }, 6 | "development": { 7 | "autoBuild": true, 8 | "publicOutputDir": "vite", 9 | "port": 3036 10 | }, 11 | "test": { 12 | "autoBuild": false, 13 | "publicOutputDir": "vite" 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000010_add_revenue_to_team_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddRevenueToTeamMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | add_column :teams, :revenue, :decimal, precision: 18, scale: 2 6 | end 7 | 8 | def self.down 9 | remove_column :teams, :revenue 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/_helpers.scss: -------------------------------------------------------------------------------- 1 | @import "helpers/clearfix"; 2 | @import "helpers/colored-links"; 3 | @import "helpers/ratio"; 4 | @import "helpers/position"; 5 | @import "helpers/stacks"; 6 | @import "helpers/visually-hidden"; 7 | @import "helpers/stretched-link"; 8 | @import "helpers/text-truncation"; 9 | @import "helpers/vr"; 10 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/create.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/edit' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | # Configuration of the edit view for a new object 9 | class Create < RailsAdmin::Config::Sections::Edit 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /lib/rails_admin/config/sections/edit.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/sections/base' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Sections 8 | # Configuration of the edit view for an existing object 9 | class Edit < RailsAdmin::Config::Sections::Base 10 | end 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/two_level/namespaced/polymorphic_association_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module TwoLevel 4 | module Namespaced 5 | class PolymorphicAssociationTest 6 | include Mongoid::Document 7 | 8 | field :name, type: String 9 | 10 | has_many :comments, as: :commentable 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_stretched-link.scss: -------------------------------------------------------------------------------- 1 | // 2 | // Stretched link 3 | // 4 | 5 | .stretched-link { 6 | &::#{$stretched-link-pseudo-element} { 7 | position: absolute; 8 | top: 0; 9 | right: 0; 10 | bottom: 0; 11 | left: 0; 12 | z-index: $stretched-link-z-index; 13 | content: ""; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000011_add_suspended_to_player_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddSuspendedToPlayerMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | add_column :players, :suspended, :boolean, default: false 6 | end 7 | 8 | def self.down 9 | remove_column :players, :suspended 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110714095433_create_balls.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateBalls < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :balls, force: true do |t| 6 | t.string :color 7 | t.timestamps null: false 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :balls 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110831090841_add_protected_field_and_restricted_field_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddProtectedFieldAndRestrictedFieldToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :restricted_field, :string 6 | add_column :field_tests, :protected_field, :string 7 | end 8 | end 9 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20111123092549_create_nested_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateNestedFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :nested_field_tests do |t| 6 | t.string :title 7 | t.integer :field_test_id 8 | 9 | t.timestamps null: false 10 | end 11 | end 12 | end 13 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_container.scss: -------------------------------------------------------------------------------- 1 | // Container mixins 2 | 3 | @mixin make-container($gutter: $container-padding-x) { 4 | width: 100%; 5 | padding-right: var(--#{$variable-prefix}gutter-x, #{$gutter}); 6 | padding-left: var(--#{$variable-prefix}gutter-x, #{$gutter}); 7 | margin-right: auto; 8 | margin-left: auto; 9 | } 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ApplicationJob < ActiveJob::Base 4 | # Automatically retry jobs that encountered a deadlock 5 | # retry_on ActiveRecord::Deadlocked 6 | 7 | # Most jobs are safe to ignore if the underlying records are no longer available 8 | # discard_on ActiveJob::DeserializationError 9 | end 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/league.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class League 4 | include Mongoid::Document 5 | 6 | field :name, type: String 7 | include Mongoid::Timestamps 8 | 9 | has_many :divisions, foreign_key: 'custom_league_id' 10 | 11 | validates_presence_of(:name) 12 | 13 | def custom_name 14 | "League '#{name}'" 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # This is a new Rails 5.0 default, so introduced as a config to ensure apps made with earlier versions of Rails aren't affected when upgrading. 6 | Rails.application.config.action_dispatch.cookies_serializer = :json 7 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/_next_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_page.last? %> 2 | 5 | <% else %> 6 | 9 | <% end %> 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/division.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Division < ActiveRecord::Base 4 | self.primary_key = :custom_id 5 | 6 | belongs_to :league, foreign_key: 'custom_league_id', optional: true 7 | has_many :teams 8 | 9 | validates_numericality_of(:custom_league_id, only_integer: true) 10 | validates_presence_of(:name) 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000009_create_fans_teams_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateFansTeamsMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :fans_teams, id: false do |t| 6 | t.integer :fan_id, :team_id 7 | end 8 | end 9 | 10 | def self.down 11 | drop_table :fans_teams 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20120720075608_create_another_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateAnotherFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :another_field_tests do |t| 6 | t.timestamps null: false 7 | end 8 | add_column :nested_field_tests, :another_field_test_id, :integer 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_stacks.scss: -------------------------------------------------------------------------------- 1 | // scss-docs-start stacks 2 | .hstack { 3 | display: flex; 4 | flex-direction: row; 5 | align-items: center; 6 | align-self: stretch; 7 | } 8 | 9 | .vstack { 10 | display: flex; 11 | flex: 1 1 auto; 12 | flex-direction: column; 13 | align-self: stretch; 14 | } 15 | // scss-docs-end stacks 16 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_alert.scss: -------------------------------------------------------------------------------- 1 | // scss-docs-start alert-variant-mixin 2 | @mixin alert-variant($background, $border, $color) { 3 | color: $color; 4 | @include gradient-bg($background); 5 | border-color: $border; 6 | 7 | .alert-link { 8 | color: shade-color($color, 20%); 9 | } 10 | } 11 | // scss-docs-end alert-variant-mixin 12 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/_prev_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_page.first? %> 2 | 5 | <% else %> 6 | 9 | <% end %> 10 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/division.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Division 4 | include Mongoid::Document 5 | include Mongoid::Timestamps 6 | 7 | field :name, type: String 8 | 9 | belongs_to :league, foreign_key: 'custom_league_id' 10 | has_many :teams 11 | 12 | validates_presence_of(:custom_league_id) 13 | validates_presence_of(:name) 14 | end 15 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110123042530_rename_histories_to_rails_admin_histories.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class RenameHistoriesToRailsAdminHistories < ActiveRecord::Migration[5.0] 4 | def self.up 5 | rename_table :histories, :rails_admin_histories 6 | end 7 | 8 | def self.down 9 | rename_table :rails_admin_histories, :histories 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110901154834_change_length_for_rails_admin_histories.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ChangeLengthForRailsAdminHistories < ActiveRecord::Migration[5.0] 4 | def up 5 | change_column :rails_admin_histories, :message, :text 6 | end 7 | 8 | def down 9 | change_column :rails_admin_histories, :message, :string 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/action_text_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | if defined?(ActionText) 6 | RSpec.describe RailsAdmin::Config::Fields::Types::ActionText do 7 | it_behaves_like 'a generic field type', :action_text_field 8 | 9 | it_behaves_like 'a string-like field type', :action_text_field 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/without_count/_next_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_page.last? %> 2 | 5 | <% else %> 6 | 9 | <% end %> 10 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_froala.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | csspath: field.css_location, 4 | jspath: field.js_location, 5 | config_options: field.config_options.to_json 6 | } 7 | %> 8 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'froala-wysiwyg', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> 9 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20140412075608_create_deeply_nested_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateDeeplyNestedFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :deeply_nested_field_tests do |t| 6 | t.belongs_to :nested_field_test 7 | t.string :title 8 | t.timestamps null: false 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_simple_mde.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | js_location: field.js_location, 4 | css_location: field.css_location, 5 | instance_config: field.instance_config 6 | } 7 | %> 8 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'simplemde', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> 9 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/citext.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 Citext < Text 10 | RailsAdmin::Config::Fields::Types.register(:citext, self) 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rails_admin/config/has_description.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Config 5 | # Provides accessor and autoregistering of model's description. 6 | module HasDescription 7 | attr_reader :description 8 | 9 | def desc(description, &_block) 10 | @description ||= description 11 | end 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/ball.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Ball 4 | include Mongoid::Document 5 | include Mongoid::Timestamps 6 | 7 | field :color, type: String 8 | 9 | has_one :comment, as: :commentable 10 | 11 | validates_presence_of :color, on: :create 12 | 13 | def to_param 14 | color.present? ? color.downcase.tr(' ', '-') : id 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000008_create_fans_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateFansMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :fans do |t| 6 | t.timestamps null: false 7 | t.string :name, limit: 100, null: false 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :fans 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/without_count/_prev_page.html.erb: -------------------------------------------------------------------------------- 1 | <% if current_page.first? %> 2 | 5 | <% else %> 6 | 9 | <% end %> 10 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_wysihtml5.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | csspath: field.css_location, 4 | jspath: field.js_location, 5 | config_options: field.config_options.to_json 6 | } 7 | %> 8 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'bootstrap-wysihtml5', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> 9 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/fan.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Fan < ActiveRecord::Base 4 | has_and_belongs_to_many :teams 5 | 6 | if ActiveRecord.gem_version >= Gem::Version.new('7.1') || defined?(CompositePrimaryKeys) 7 | has_many :fanships, inverse_of: :fan 8 | has_one :fanship, inverse_of: :fan 9 | end 10 | 11 | validates_presence_of(:name) 12 | end 13 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/inet.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 Inet < RailsAdmin::Config::Fields::Base 10 | RailsAdmin::Config::Fields::Types.register(self) 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000003_create_leagues_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateLeaguesMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :leagues do |t| 6 | t.timestamps null: false 7 | t.string :name, limit: 50, null: false 8 | end 9 | end 10 | 11 | def self.down 12 | drop_table :leagues 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_code_mirror.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | csspath: field.css_location, 4 | jspath: field.js_location, 5 | options: field.config, 6 | locations: field.assets 7 | } 8 | %> 9 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'codemirror', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> 10 | -------------------------------------------------------------------------------- /spec/dummy_app/config/boot.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | CI_ORM = (ENV['CI_ORM'] || :active_record).to_sym unless defined?(CI_ORM) 4 | CI_TARGET_ORMS = %i[active_record mongoid].freeze 5 | CI_ASSET = (ENV['CI_ASSET'] || :sprockets).to_sym unless defined?(CI_ASSET) 6 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 7 | 8 | require 'bundler/setup' # Set up gems listed in the Gemfile. 9 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20120928075608_create_images.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateImages < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :images do |t| 6 | t.string :file_file_name 7 | t.string :file_content_type 8 | t.bigint :file_file_size 9 | t.datetime :file_updated_at 10 | t.timestamps null: false 11 | end 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20210811121027_create_two_level_namespaced_polymorphic_association_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateTwoLevelNamespacedPolymorphicAssociationTests < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :two_level_namespaced_polymorphic_association_tests do |t| 6 | t.string :name 7 | 8 | t.timestamps 9 | end 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/uuid.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/fields/types/string' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Fields 8 | module Types 9 | class Uuid < RailsAdmin::Config::Fields::Types::String 10 | RailsAdmin::Config::Fields::Types.register(self) 11 | end 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/rails_admin/jquery-ui/version.js: -------------------------------------------------------------------------------- 1 | ( function( factory ) { 2 | if ( typeof define === "function" && define.amd ) { 3 | 4 | // AMD. Register as an anonymous module. 5 | define( [ "jquery" ], factory ); 6 | } else { 7 | 8 | // Browser globals 9 | factory( jQuery ); 10 | } 11 | } ( function( $ ) { 12 | 13 | $.ui = $.ui || {}; 14 | 15 | return $.ui.version = "1.12.1"; 16 | 17 | } ) ); 18 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110328193014_create_cms_basic_pages.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateCmsBasicPages < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :cms_basic_pages do |t| 6 | t.string :title 7 | t.text :content 8 | 9 | t.timestamps null: false 10 | end 11 | end 12 | 13 | def self.down 14 | drop_table :cms_basic_pages 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20111108143642_add_dragonfly_and_carrierwave_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddDragonflyAndCarrierwaveToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :paperclip_asset_file_name, :string 6 | add_column :field_tests, :dragonfly_asset_uid, :string 7 | add_column :field_tests, :carrierwave_asset, :string 8 | end 9 | end 10 | -------------------------------------------------------------------------------- /spec/integration/fields/color_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'Color field', type: :request do 6 | subject { page } 7 | 8 | it 'uses HTML5 color picker' do 9 | RailsAdmin.config Team do 10 | field :color, :color 11 | end 12 | visit new_path(model_name: 'team') 13 | is_expected.to have_selector('#team_color[type="color"]') 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rails_admin/extensions/url_for_extension.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Extensions 5 | module UrlForExtension 6 | def url_for(options, *args) 7 | case options[:id] 8 | when Array 9 | options[:id] = RailsAdmin.config.composite_keys_serializer.serialize(options[:id]) 10 | end 11 | super options, *args 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /lib/rails_admin/support/composite_keys_serializer.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Support 5 | module CompositeKeysSerializer 6 | def self.serialize(keys) 7 | keys.map { |key| key&.to_s&.gsub('_', '__') }.join('_') 8 | end 9 | 10 | def self.deserialize(string) 11 | string.split('_').map { |key| key&.gsub('__', '_') } 12 | end 13 | end 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/league.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class League < ActiveRecord::Base 4 | has_many :divisions, foreign_key: 'custom_league_id' 5 | has_many :teams, -> { readonly }, through: :divisions 6 | has_many :players, through: :teams 7 | has_one :division, foreign_key: 'custom_league_id' 8 | 9 | validates_presence_of(:name) 10 | 11 | def custom_name 12 | "League '#{name}'" 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000001_create_divisions_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateDivisionsMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :divisions do |t| 6 | t.timestamps null: false 7 | t.integer :league_id 8 | t.string :name, limit: 50, null: false 9 | end 10 | end 11 | 12 | def self.down 13 | drop_table(:divisions) 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110103205808_create_comments.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateComments < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :comments do |t| 6 | t.integer :commentable_id 7 | t.string :commentable_type 8 | t.text :content 9 | 10 | t.timestamps null: false 11 | end 12 | end 13 | 14 | def self.down 15 | drop_table :comments 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_colored-links.scss: -------------------------------------------------------------------------------- 1 | @each $color, $value in $theme-colors { 2 | .link-#{$color} { 3 | color: $value; 4 | 5 | @if $link-shade-percentage != 0 { 6 | &:hover, 7 | &:focus { 8 | color: if(color-contrast($value) == $color-contrast-light, shade-color($value, $link-shade-percentage), tint-color($value, $link-shade-percentage)); 9 | } 10 | } 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_backdrop.scss: -------------------------------------------------------------------------------- 1 | // Shared between modals and offcanvases 2 | @mixin overlay-backdrop($zindex, $backdrop-bg, $backdrop-opacity) { 3 | position: fixed; 4 | top: 0; 5 | left: 0; 6 | z-index: $zindex; 7 | width: 100vw; 8 | height: 100vh; 9 | background-color: $backdrop-bg; 10 | 11 | // Fade for backdrop 12 | &.fade { opacity: 0; } 13 | &.show { opacity: $backdrop-opacity; } 14 | } 15 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20101223222233_create_rel_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateRelTests < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :rel_tests do |t| 6 | t.integer :league_id 7 | t.integer :division_id, null: false 8 | t.integer :player_id 9 | 10 | t.timestamps null: false 11 | end 12 | end 13 | 14 | def self.down 15 | drop_table :rel_tests 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20120319041705_drop_rel_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class DropRelTests < ActiveRecord::Migration[5.0] 4 | def self.up 5 | drop_table :rel_tests 6 | end 7 | 8 | def self.down 9 | create_table :rel_tests do |t| 10 | t.integer :league_id 11 | t.integer :division_id, null: false 12 | t.integer :player_id 13 | 14 | t.timestamps null: false 15 | end 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20150815102450_add_refile_to_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class AddRefileToFieldTests < ActiveRecord::Migration[5.0] 4 | def change 5 | add_column :field_tests, :refile_asset_id, :string 6 | add_column :field_tests, :refile_asset_filename, :string 7 | add_column :field_tests, :refile_asset_size, :string 8 | add_column :field_tests, :refile_asset_content_type, :string 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /spec/integration/fields/paperclip_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'Paperclip field', type: :request do 6 | subject { page } 7 | 8 | it 'shows a file upload field' do 9 | RailsAdmin.config User do 10 | edit do 11 | field :avatar 12 | end 13 | end 14 | visit new_path(model_name: 'user') 15 | is_expected.to have_selector('input#user_avatar') 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/support/fakeio.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'forwardable' 4 | require 'stringio' 5 | 6 | class FakeIO 7 | attr_reader :original_filename, :content_type 8 | 9 | def initialize(content, filename: nil, content_type: nil) 10 | @io = StringIO.new(content) 11 | @original_filename = filename 12 | @content_type = content_type 13 | end 14 | 15 | extend Forwardable 16 | delegate %i[read rewind eof? close size] => :@io 17 | end 18 | -------------------------------------------------------------------------------- /spec/dummy_app/config/mongoid5.yml: -------------------------------------------------------------------------------- 1 | defaults: &defaults 2 | use_utc: false 3 | use_activesupport_time_zone: true 4 | 5 | development: 6 | <<: *defaults 7 | database: dummy_app_development 8 | clients: 9 | default: 10 | database: dummy_app_development 11 | hosts: 12 | - 127.0.0.1:27017 13 | 14 | test: 15 | <<: *defaults 16 | clients: 17 | default: 18 | database: dummy_app_test 19 | hosts: 20 | - 127.0.0.1:27017 21 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/timestamp.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/fields/types/datetime' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Fields 8 | module Types 9 | class Timestamp < RailsAdmin::Config::Fields::Types::Datetime 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 | -------------------------------------------------------------------------------- /spec/rails_admin/config/has_description_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::HasDescription do 6 | it 'shows description message when added through the DSL' do 7 | RailsAdmin.config do |config| 8 | config.model Team do 9 | desc 'Description of Team model' 10 | end 11 | end 12 | 13 | expect(RailsAdmin.config(Team).description).to eq('Description of Team model') 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20140826093552_create_versions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateVersions < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :versions do |t| 6 | t.string :item_type, null: false 7 | t.integer :item_id, null: false 8 | t.string :event, null: false 9 | t.string :whodunnit 10 | t.text :object 11 | t.datetime :created_at 12 | end 13 | add_index :versions, %i[item_type item_id] 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/managing_user.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class ManagingUser < User 4 | has_one :team, class_name: 'ManagedTeam', foreign_key: :manager, primary_key: :email, inverse_of: :user 5 | has_many :teams, class_name: 'ManagedTeam', foreign_key: :manager, primary_key: :email, inverse_of: :user 6 | has_and_belongs_to_many :players, foreign_key: :player_names, primary_key: :name, inverse_of: :nil 7 | has_and_belongs_to_many :balls, primary_key: :color, inverse_of: :nil 8 | end 9 | -------------------------------------------------------------------------------- /spec/integration/fields/ck_editor_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'CKEditor 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, :ck_editor 12 | end 13 | end 14 | expect { visit new_path(model_name: 'draft') }.not_to raise_error 15 | is_expected.to have_selector('#cke_draft_notes') 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/integration/fields/code_mirror_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'CodeMirror 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, :code_mirror 12 | end 13 | end 14 | expect { visit new_path(model_name: 'draft') }.not_to raise_error 15 | is_expected.to have_selector('.CodeMirror') 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /spec/dummy_app/bin/webpack: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "bundler/setup" 11 | 12 | require "webpacker" 13 | require "webpacker/webpack_runner" 14 | 15 | APP_ROOT = File.expand_path("..", __dir__) 16 | Dir.chdir(APP_ROOT) do 17 | Webpacker::WebpackRunner.run(ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /spec/integration/fields/simple_mde_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'SimpleMDE 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, :simple_mde 12 | end 13 | end 14 | expect { visit new_path(model_name: 'draft') }.not_to raise_error 15 | is_expected.to have_selector('a[title="Markdown Guide"]') 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/assets/stylesheets/rails_admin/custom/theming.scss: -------------------------------------------------------------------------------- 1 | /* 2 | Customize RailsAdmin theme here. 3 | Copy this file to your app/assets/stylesheets/rails_admin/custom/theming.scss, leave this one untouched 4 | Don't require it in your application.rb 5 | 6 | Look at the markup in RailsAdmin and go there to get inspiration from: 7 | 8 | http://getbootstrap.com 9 | 10 | Test me: (actual color should be the one defined in variables.scss if you did) 11 | 12 | body { background-color: $link-color; } 13 | */ 14 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_ck_editor.html.erb: -------------------------------------------------------------------------------- 1 | <% 2 | js_data = { 3 | jspath: field.location ? field.location : field.base_location + "ckeditor.js", 4 | base_location: field.base_location, 5 | options: { 6 | customConfig: field.config_js ? field.config_js : field.base_location + "config.js" 7 | } 8 | } 9 | %> 10 | <%= form.text_area field.method_name, field.html_attributes.reverse_merge(data: { richtext: 'ckeditor', options: js_data.to_json }).reverse_merge({ value: field.form_value }) %> 11 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/has_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 HasManyAssociation < 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 | -------------------------------------------------------------------------------- /spec/dummy_app/app/active_record/draft.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Draft < ActiveRecord::Base 4 | belongs_to :team 5 | belongs_to :player 6 | 7 | validates_numericality_of(:player_id, only_integer: true) 8 | validates_numericality_of(:team_id, only_integer: true) 9 | validates_presence_of(:date) 10 | validates_numericality_of(:round, only_integer: true) 11 | validates_numericality_of(:pick, only_integer: true) 12 | validates_numericality_of(:overall, only_integer: true) 13 | end 14 | -------------------------------------------------------------------------------- /spec/dummy_app/app/locales/models.en.yml: -------------------------------------------------------------------------------- 1 | en: 2 | activerecord: &en_attributes 3 | attributes: 4 | fan: 5 | name: Their Name 6 | team: 7 | manager: Team Manager 8 | main_sponsor: Main Sponsor 9 | fans: Some Fans 10 | mongoid: *en_attributes 11 | fr: 12 | activerecord: &fr_attributes 13 | attributes: 14 | fan: 15 | name: Son nom 16 | team: 17 | manager: Manager de l'équipe 18 | fans: Quelques fans 19 | mongoid: *fr_attributes 20 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | # Be sure to restart your server when you modify this file. 4 | 5 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 6 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 7 | 8 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 9 | # Rails.backtrace_cleaner.remove_silencers! 10 | -------------------------------------------------------------------------------- /vendor/assets/javascripts/rails_admin/jquery-ui/ie.js: -------------------------------------------------------------------------------- 1 | //= require rails_admin/jquery-ui/version 2 | 3 | ( function( factory ) { 4 | if ( typeof define === "function" && define.amd ) { 5 | 6 | // AMD. Register as an anonymous module. 7 | define( [ "jquery", "./version" ], factory ); 8 | } else { 9 | 10 | // Browser globals 11 | factory( jQuery ); 12 | } 13 | } ( function( $ ) { 14 | 15 | // This file is deprecated 16 | return $.ui.ie = !!/msie [\w.]+/.exec( navigator.userAgent.toLowerCase() ); 17 | } ) ); 18 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_image.scss: -------------------------------------------------------------------------------- 1 | // Image Mixins 2 | // - Responsive image 3 | // - Retina image 4 | 5 | 6 | // Responsive image 7 | // 8 | // Keep images from scaling beyond the width of their parents. 9 | 10 | @mixin img-fluid { 11 | // Part 1: Set a maximum relative to the parent 12 | max-width: 100%; 13 | // Part 2: Override the height to auto, otherwise images will be stretched 14 | // when setting a width and height attribute on the img element. 15 | height: auto; 16 | } 17 | -------------------------------------------------------------------------------- /spec/dummy_app/bin/webpack-dev-server: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | ENV["RAILS_ENV"] ||= ENV["RACK_ENV"] || "development" 4 | ENV["NODE_ENV"] ||= "development" 5 | 6 | require "pathname" 7 | ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../../Gemfile", 8 | Pathname.new(__FILE__).realpath) 9 | 10 | require "bundler/setup" 11 | 12 | require "webpacker" 13 | require "webpacker/dev_server_runner" 14 | 15 | APP_ROOT = File.expand_path("..", __dir__) 16 | Dir.chdir(APP_ROOT) do 17 | Webpacker::DevServerRunner.run(ARGV) 18 | end 19 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20210812115908_create_custom_versions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateCustomVersions < ActiveRecord::Migration[5.0] 4 | def change 5 | create_table :custom_versions do |t| 6 | t.string :item_type, null: false 7 | t.integer :item_id, null: false 8 | t.string :event, null: false 9 | t.string :whodunnit 10 | t.text :object 11 | t.datetime :created_at 12 | end 13 | add_index :custom_versions, %i[item_type item_id] 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /app/views/kaminari/ra-twitter-bootstrap/_paginator.html.erb: -------------------------------------------------------------------------------- 1 | <%= paginator.render do %> 2 | 15 | <% end %> 16 | -------------------------------------------------------------------------------- /spec/dummy_app/config/mongoid6.yml: -------------------------------------------------------------------------------- 1 | defaults: &defaults 2 | use_utc: false 3 | use_activesupport_time_zone: true 4 | options: 5 | belongs_to_required_by_default: false 6 | 7 | development: 8 | <<: *defaults 9 | database: dummy_app_development 10 | clients: 11 | default: 12 | database: dummy_app_development 13 | hosts: 14 | - 127.0.0.1:27017 15 | 16 | test: 17 | <<: *defaults 18 | clients: 19 | default: 20 | database: dummy_app_test 21 | hosts: 22 | - 127.0.0.1:27017 23 | -------------------------------------------------------------------------------- /spec/rails_admin/adapters/active_record/object_extension_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe 'RailsAdmin::Adapters::ActiveRecord::ObjectExtension', active_record: true do 6 | describe '#assign_attributes' do 7 | let(:player) { Player.new } 8 | let(:object) { player.extend RailsAdmin::Adapters::ActiveRecord::ObjectExtension } 9 | 10 | it 'does not cause error with nil' do 11 | expect(object.assign_attributes(nil)).to be nil 12 | end 13 | end 14 | end 15 | -------------------------------------------------------------------------------- /.teatro.yml: -------------------------------------------------------------------------------- 1 | project: 2 | platform: rails 3 | 4 | stage: 5 | before: 6 | - export CI_DB_ADAPTER=postgresql 7 | - export CI_ORM=active_record 8 | - cp Procfile.teatro Procfile 9 | - cd spec/dummy_app 10 | - cp ../../config/database.yml config/ 11 | - bundle install --without development --jobs=3 --retry=3 12 | - ln -sf $PWD/public ../../public 13 | 14 | database: 15 | - bundle exec rake db:create db:migrate db:seed 16 | 17 | config: 18 | database: postgresql 19 | services: 20 | - postgresql 21 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000007_create_histories_table.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateHistoriesTable < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :histories do |t| 6 | t.string :message # title, name, or object_id 7 | t.string :username 8 | t.integer :item 9 | t.string :table 10 | t.timestamps null: false 11 | end 12 | add_index(:histories, %i[item table]) 13 | end 14 | 15 | def self.down 16 | drop_table :histories 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /app/views/rails_admin/main/_form_datetime.html.erb: -------------------------------------------------------------------------------- 1 |
    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 | DummyApp 5 | <% case CI_ASSET %> 6 | <% when :webpacker %> 7 | <%= javascript_pack_tag "application" %> 8 | <% when :importmap %> 9 | <%= javascript_importmap_tags %> 10 | <% when :vite %> 11 | <%= vite_client_tag %> 12 | <%= vite_javascript_tag 'application' %> 13 | <% else %> 14 | <%= stylesheet_link_tag "application", media: "all" %> 15 | <%= javascript_include_tag "application", type: 'module' %> 16 | <% end %> 17 | <%= csrf_meta_tags %> 18 | 19 | 20 | 21 | <%= yield %> 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_list-group.scss: -------------------------------------------------------------------------------- 1 | // List Groups 2 | 3 | // scss-docs-start list-group-mixin 4 | @mixin list-group-item-variant($state, $background, $color) { 5 | .list-group-item-#{$state} { 6 | color: $color; 7 | background-color: $background; 8 | 9 | &.list-group-item-action { 10 | &:hover, 11 | &:focus { 12 | color: $color; 13 | background-color: shade-color($background, 10%); 14 | } 15 | 16 | &.active { 17 | color: $white; 18 | background-color: $color; 19 | border-color: $color; 20 | } 21 | } 22 | } 23 | } 24 | // scss-docs-end list-group-mixin 25 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000004_create_players_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreatePlayersMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :players do |t| 6 | t.timestamps null: false 7 | t.datetime :deleted_at 8 | t.integer :team_id 9 | t.string :name, limit: 100, null: false 10 | t.string :position, limit: 50 11 | t.integer :number, null: false 12 | t.boolean :retired, default: false 13 | t.boolean :injured, default: false 14 | t.date :born_on 15 | t.text :notes 16 | end 17 | end 18 | 19 | def self.down 20 | drop_table :players 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110224184303_create_field_tests.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateFieldTests < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :field_tests do |t| 6 | t.string :string_field 7 | t.text :text_field 8 | t.integer :integer_field 9 | t.float :float_field 10 | t.decimal :decimal_field 11 | t.datetime :datetime_field 12 | t.timestamp :timestamp_field 13 | t.time :time_field 14 | t.date :date_field 15 | t.boolean :boolean_field 16 | 17 | t.timestamps null: false 18 | end 19 | end 20 | 21 | def self.down 22 | drop_table :field_tests 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/rails_admin/active_record_extension_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | require File.expand_path('../../config/initializers/active_record_extensions', __dir__) 5 | 6 | RSpec.describe 'ActiveRecord::Base', active_record: true do 7 | describe '#safe_send' do 8 | it 'only calls #read_attribute once' do 9 | @player = Player.new 10 | @player.number = 23 11 | original_method = @player.method(:read_attribute) 12 | expect(@player).to receive(:read_attribute).exactly(1).times do |*args| 13 | original_method.call(*args) 14 | end 15 | expect(@player.safe_send(:number)).to eq(23) 16 | end 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/rails_admin/config/fields/types/paperclip_spec.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'spec_helper' 4 | 5 | RSpec.describe RailsAdmin::Config::Fields::Types::Paperclip do 6 | it_behaves_like 'a generic field type', :string_field, :paperclip 7 | 8 | context 'when a *_file_name field exists but not declared as has_attached_file' do 9 | before do 10 | class PaperclipTest < Tableless 11 | column :some_file_name, :varchar 12 | end 13 | RailsAdmin.config.included_models = [PaperclipTest] 14 | end 15 | 16 | it 'does not break' do 17 | expect { RailsAdmin.config(PaperclipTest).fields }.not_to raise_error 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /src/rails_admin/styles/base.scss: -------------------------------------------------------------------------------- 1 | @charset "UTF-8"; 2 | 3 | /*** Variables & mixins ***/ 4 | 5 | @import "base/variables"; 6 | @import "base/mixins"; 7 | 8 | /*** Libraries ***/ 9 | 10 | @import "flatpickr/dist/flatpickr"; 11 | 12 | /*** Font-awesome ***/ 13 | 14 | $fa-font-path: "~@fortawesome/fontawesome-free/webfonts" !default; 15 | @import "@fortawesome/fontawesome-free/scss/solid"; 16 | @import "@fortawesome/fontawesome-free/scss/fontawesome"; 17 | 18 | /*** Bootstrap ***/ 19 | 20 | @import "bootstrap/scss/bootstrap"; 21 | 22 | /*** RailsAdmin ***/ 23 | 24 | @import "base/theming"; 25 | @import "filtering-select"; 26 | @import "filtering-multiselect"; 27 | @import "widgets"; 28 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/nested_field_test.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class NestedFieldTest 4 | include Mongoid::Document 5 | 6 | field :title, type: String 7 | belongs_to :field_test, inverse_of: :nested_field_tests 8 | belongs_to :another_field_test, inverse_of: :nested_field_tests 9 | include Mongoid::Timestamps 10 | 11 | has_many :deeply_nested_field_tests, inverse_of: :nested_field_test 12 | accepts_nested_attributes_for :deeply_nested_field_tests, allow_destroy: true 13 | has_one :comment, as: :commentable, autosave: true 14 | accepts_nested_attributes_for :comment, allow_destroy: true, reject_if: proc { |attributes| attributes['content'].blank? } 15 | end 16 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/helpers/_position.scss: -------------------------------------------------------------------------------- 1 | // Shorthand 2 | 3 | .fixed-top { 4 | position: fixed; 5 | top: 0; 6 | right: 0; 7 | left: 0; 8 | z-index: $zindex-fixed; 9 | } 10 | 11 | .fixed-bottom { 12 | position: fixed; 13 | right: 0; 14 | bottom: 0; 15 | left: 0; 16 | z-index: $zindex-fixed; 17 | } 18 | 19 | // Responsive sticky top 20 | @each $breakpoint in map-keys($grid-breakpoints) { 21 | @include media-breakpoint-up($breakpoint) { 22 | $infix: breakpoint-infix($breakpoint, $grid-breakpoints); 23 | 24 | .sticky#{$infix}-top { 25 | position: sticky; 26 | top: 0; 27 | z-index: $zindex-sticky; 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /vendor/assets/stylesheets/rails_admin/bootstrap/mixins/_deprecate.scss: -------------------------------------------------------------------------------- 1 | // Deprecate mixin 2 | // 3 | // This mixin can be used to deprecate mixins or functions. 4 | // `$enable-deprecation-messages` is a global variable, `$ignore-warning` is a variable that can be passed to 5 | // some deprecated mixins to suppress the warning (for example if the mixin is still be used in the current version of Bootstrap) 6 | @mixin deprecate($name, $deprecate-version, $remove-version, $ignore-warning: false) { 7 | @if ($enable-deprecation-messages != false and $ignore-warning != true) { 8 | @warn "#{$name} has been deprecated as of #{$deprecate-version}. It will be removed entirely in #{$remove-version}."; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /spec/dummy_app/config/database.yml: -------------------------------------------------------------------------------- 1 | sqlite: &sqlite 2 | adapter: sqlite3 3 | pool: 5 4 | timeout: 5000 5 | 6 | postgresql: 7 | adapter: postgresql 8 | database: rails_admin 9 | username: postgres 10 | password: 11 | host: 127.0.0.1 12 | encoding: utf8 13 | pool: 5 14 | timeout: 5000 15 | 16 | mysql: 17 | adapter: mysql2 18 | database: rails_admin 19 | username: root 20 | password: 21 | host: 127.0.0.1 22 | encoding: utf8 23 | pool: 5 24 | timeout: 5000 25 | 26 | development: 27 | <<: *sqlite 28 | database: db/development.sqlite3 29 | 30 | test: 31 | <<: *sqlite 32 | database: db/test.sqlite3 33 | 34 | production: 35 | <<: *sqlite 36 | database: db/production.sqlite3 37 | -------------------------------------------------------------------------------- /app/views/layouts/rails_admin/_navigation.html.erb: -------------------------------------------------------------------------------- 1 |
    2 | 3 | <%= _get_plugin_name[0] || 'Rails' %> 4 | 5 | <%= _get_plugin_name[1] || 'Admin' %> 6 | 7 | 8 | 14 | 17 |
    18 | -------------------------------------------------------------------------------- /spec/dummy_app/app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts, 5 | // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // the compiled file. 9 | // 10 | // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD 11 | // GO AFTER THE REQUIRES BELOW. 12 | // 13 | //= require rails-ujs.esm 14 | //= require turbo 15 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/session_patch.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'action_dispatch/middleware/session/abstract_store' 4 | 5 | # When ORM was switched, but another ORM's model class still exists in session 6 | # (Devise saves User model to session), ActionDispatch raises ActionDispatch::Session::SessionRestoreError 7 | # and app can't be started unless you delete your browser's cookie data. 8 | # To prevent this situation, detect this problem here and reset session data 9 | # so user can make another login via Devise. 10 | 11 | ActionDispatch::Session::StaleSessionCheck.module_eval do 12 | def stale_session_check! 13 | yield 14 | rescue ArgumentError 15 | {} 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /lib/rails_admin/config/groupable.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | require 'rails_admin/config/fields/group' 4 | 5 | module RailsAdmin 6 | module Config 7 | module Groupable 8 | # Register a group instance variable and accessor methods for objects 9 | # extending the has groups mixin. The extended objects must implement 10 | # reader for a parent object which includes this module. 11 | # 12 | # @see RailsAdmin::Config::HasGroups.group 13 | # @see RailsAdmin::Config::Fields::Group 14 | def group(name = nil) 15 | @group = parent.group(name) unless name.nil? # setter 16 | @group ||= parent.group(:default) # getter 17 | end 18 | end 19 | end 20 | end 21 | -------------------------------------------------------------------------------- /spec/dummy_app/config/initializers/rails_admin.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | RailsAdmin.config do |c| 4 | c.asset_source = CI_ASSET 5 | c.model Team do 6 | include_all_fields 7 | field :color, :hidden 8 | end 9 | 10 | if Rails.env.production? 11 | # Live demo configuration 12 | c.main_app_name = ['RailsAdmin', 'Live Demo'] 13 | c.included_models = %w[Comment Division Draft Fan FieldTest League NestedFieldTest Player Team User] 14 | c.model 'FieldTest' do 15 | configure :paperclip_asset do 16 | visible false 17 | end 18 | end 19 | c.model 'League' do 20 | configure :players do 21 | visible false 22 | end 23 | end 24 | end 25 | end 26 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class SetPrimaryKeyNotNullForDivisions < ActiveRecord::Migration[5.0] 4 | def up 5 | drop_table :divisions 6 | create_table :divisions, id: false do |t| 7 | t.timestamps null: false 8 | t.primary_key :custom_id 9 | t.integer :custom_league_id 10 | t.string :name, limit: 50, null: false 11 | end 12 | end 13 | 14 | def down 15 | drop_table :divisions 16 | create_table :divisions, primary_key: :custom_id do |t| 17 | t.timestamps null: false 18 | t.integer :custom_league_id 19 | t.string :name, limit: 50, null: false 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/dummy_app/db/migrate/00000000000005_create_teams_migration.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class CreateTeamsMigration < ActiveRecord::Migration[5.0] 4 | def self.up 5 | create_table :teams do |t| 6 | t.timestamps null: false 7 | t.integer :league_id 8 | t.integer :division_id 9 | t.string :name, limit: 50 10 | t.string :logo_url, limit: 255 11 | t.string :manager, limit: 100, null: false 12 | t.string :ballpark, limit: 100 13 | t.string :mascot, limit: 100 14 | t.integer :founded 15 | t.integer :wins 16 | t.integer :losses 17 | t.float :win_percentage 18 | end 19 | end 20 | 21 | def self.down 22 | drop_table :teams 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/numeric.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 Numeric < RailsAdmin::Config::Fields::Base 10 | # Register field type for the type loader 11 | RailsAdmin::Config::Fields::Types.register(self) 12 | 13 | register_instance_option :filter_operators do 14 | %w[default between] + (required? ? [] : %w[_separator _not_null _null]) 15 | end 16 | 17 | register_instance_option :view_helper do 18 | :number_field 19 | end 20 | end 21 | end 22 | end 23 | end 24 | end 25 | -------------------------------------------------------------------------------- /spec/dummy_app/app/mongoid/draft.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | class Draft 4 | include Mongoid::Document 5 | include Mongoid::Timestamps 6 | 7 | belongs_to :player 8 | belongs_to :team 9 | field :date, type: Date 10 | field :round, type: Integer 11 | field :pick, type: Integer 12 | field :overall, type: Integer 13 | field :college, type: String 14 | field :notes, type: String 15 | 16 | validates_presence_of(:player_id, only_integer: true) 17 | validates_presence_of(:team_id, only_integer: true) 18 | validates_presence_of(:date) 19 | validates_numericality_of(:round, only_integer: true) 20 | validates_numericality_of(:pick, only_integer: true) 21 | validates_numericality_of(:overall, only_integer: true) 22 | end 23 | -------------------------------------------------------------------------------- /lib/rails_admin/config/fields/types/text.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 Text < StringLike 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 | cols: '48', 17 | rows: '3', 18 | } 19 | end 20 | 21 | register_instance_option :partial do 22 | :form_text 23 | end 24 | end 25 | end 26 | end 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /lib/generators/rails_admin/utils.rb: -------------------------------------------------------------------------------- 1 | # frozen_string_literal: true 2 | 3 | module RailsAdmin 4 | module Generators 5 | module Utils 6 | module InstanceMethods 7 | def display(output, color = :green) 8 | say(" - #{output}", color) 9 | end 10 | 11 | def ask_for(wording, default_value = nil, override_if_present_value = nil) 12 | if override_if_present_value.present? 13 | display("Using [#{override_if_present_value}] for question '#{wording}'") && override_if_present_value 14 | else 15 | ask(" ? #{wording} Press 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 | 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 | 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 | --------------------------------------------------------------------------------