mini-max-mod 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/administrate-1.0.0/Rakefile +30 -0
- data/administrate-1.0.0/app/assets/builds/administrate/application.css +2614 -0
- data/administrate-1.0.0/app/assets/builds/administrate/application.css.map +1 -0
- data/administrate-1.0.0/app/assets/builds/administrate/application.js +31661 -0
- data/administrate-1.0.0/app/assets/builds/administrate/application.js.map +7 -0
- data/administrate-1.0.0/app/assets/builds/administrate-internal/docs.css +102 -0
- data/administrate-1.0.0/app/assets/builds/administrate-internal/docs.css.map +1 -0
- data/administrate-1.0.0/app/assets/config/administrate_manifest.js +2 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/add_jquery.js +4 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/application.js +9 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/controllers/application.js +9 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/controllers/index.js +9 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/controllers/select_controller.js +25 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/controllers/table_controller.js +23 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/controllers/tooltip_controller.js +24 -0
- data/administrate-1.0.0/app/assets/javascripts/administrate/vendor/css-anchor-positioning.js +9310 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/application.scss +29 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/base/_forms.scss +107 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/base/_layout.scss +25 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/base/_lists.scss +19 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/base/_tables.scss +58 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/base/_typography.scss +59 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_app-container.scss +9 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_attributes.scss +28 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_buttons.scss +88 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_cells.scss +54 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_field-unit.scss +56 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_flashes.scss +20 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_form-actions.scss +3 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_main-content.scss +30 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_navigation.scss +32 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_pagination.scss +18 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/components/_search.scss +87 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/library/_clearfix.scss +7 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/library/_data-label.scss +8 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/library/_variables.scss +69 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate/reset/_normalize.scss +453 -0
- data/administrate-1.0.0/app/assets/stylesheets/administrate-internal/docs.scss +95 -0
- data/administrate-1.0.0/app/controllers/administrate/application_controller.rb +279 -0
- data/administrate-1.0.0/app/controllers/concerns/administrate/punditize.rb +52 -0
- data/administrate-1.0.0/app/helpers/administrate/application_helper.rb +101 -0
- data/administrate-1.0.0/app/views/administrate/application/_collection.html.erb +102 -0
- data/administrate-1.0.0/app/views/administrate/application/_collection_header_actions.html.erb +4 -0
- data/administrate-1.0.0/app/views/administrate/application/_collection_item_actions.html.erb +17 -0
- data/administrate-1.0.0/app/views/administrate/application/_flashes.html.erb +21 -0
- data/administrate-1.0.0/app/views/administrate/application/_form.html.erb +60 -0
- data/administrate-1.0.0/app/views/administrate/application/_icons.html.erb +21 -0
- data/administrate-1.0.0/app/views/administrate/application/_index_header.html.erb +51 -0
- data/administrate-1.0.0/app/views/administrate/application/_javascript.html.erb +21 -0
- data/administrate-1.0.0/app/views/administrate/application/_navigation.html.erb +20 -0
- data/administrate-1.0.0/app/views/administrate/application/_pagination.html.erb +1 -0
- data/administrate-1.0.0/app/views/administrate/application/_search.html.erb +25 -0
- data/administrate-1.0.0/app/views/administrate/application/_stylesheet.html.erb +14 -0
- data/administrate-1.0.0/app/views/administrate/application/edit.html.erb +48 -0
- data/administrate-1.0.0/app/views/administrate/application/index.html.erb +55 -0
- data/administrate-1.0.0/app/views/administrate/application/new.html.erb +49 -0
- data/administrate-1.0.0/app/views/administrate/application/show.html.erb +77 -0
- data/administrate-1.0.0/app/views/fields/belongs_to/_form.html.erb +27 -0
- data/administrate-1.0.0/app/views/fields/belongs_to/_index.html.erb +27 -0
- data/administrate-1.0.0/app/views/fields/belongs_to/_show.html.erb +27 -0
- data/administrate-1.0.0/app/views/fields/boolean/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/boolean/_index.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/boolean/_show.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/date/_form.html.erb +22 -0
- data/administrate-1.0.0/app/views/fields/date/_index.html.erb +21 -0
- data/administrate-1.0.0/app/views/fields/date/_show.html.erb +21 -0
- data/administrate-1.0.0/app/views/fields/date_time/_form.html.erb +22 -0
- data/administrate-1.0.0/app/views/fields/date_time/_index.html.erb +21 -0
- data/administrate-1.0.0/app/views/fields/date_time/_show.html.erb +21 -0
- data/administrate-1.0.0/app/views/fields/email/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/email/_index.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/email/_show.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/has_many/_form.html.erb +29 -0
- data/administrate-1.0.0/app/views/fields/has_many/_index.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/has_many/_show.html.erb +39 -0
- data/administrate-1.0.0/app/views/fields/has_one/_form.html.erb +44 -0
- data/administrate-1.0.0/app/views/fields/has_one/_index.html.erb +24 -0
- data/administrate-1.0.0/app/views/fields/has_one/_show.html.erb +47 -0
- data/administrate-1.0.0/app/views/fields/number/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/number/_index.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/number/_show.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/password/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/password/_index.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/password/_show.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/polymorphic/_form.html.erb +29 -0
- data/administrate-1.0.0/app/views/fields/polymorphic/_index.html.erb +25 -0
- data/administrate-1.0.0/app/views/fields/polymorphic/_show.html.erb +28 -0
- data/administrate-1.0.0/app/views/fields/rich_text/_form.html.erb +22 -0
- data/administrate-1.0.0/app/views/fields/rich_text/_index.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/rich_text/_show.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/select/_form.html.erb +33 -0
- data/administrate-1.0.0/app/views/fields/select/_index.html.erb +16 -0
- data/administrate-1.0.0/app/views/fields/select/_show.html.erb +16 -0
- data/administrate-1.0.0/app/views/fields/string/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/string/_index.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/string/_show.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/text/_form.html.erb +22 -0
- data/administrate-1.0.0/app/views/fields/text/_index.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/text/_show.html.erb +18 -0
- data/administrate-1.0.0/app/views/fields/time/_form.html.erb +22 -0
- data/administrate-1.0.0/app/views/fields/time/_index.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/time/_show.html.erb +19 -0
- data/administrate-1.0.0/app/views/fields/url/_form.html.erb +23 -0
- data/administrate-1.0.0/app/views/fields/url/_index.html.erb +20 -0
- data/administrate-1.0.0/app/views/fields/url/_show.html.erb +20 -0
- data/administrate-1.0.0/app/views/layouts/administrate/application.html.erb +41 -0
- data/administrate-1.0.0/config/locales/administrate.ar.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.bs.yml +29 -0
- data/administrate-1.0.0/config/locales/administrate.ca.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.da.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.de.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.en.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.es.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.fi.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.fr.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.id.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.it.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.ja.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.ko.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.nl.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.pl.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.pt-BR.yml +31 -0
- data/administrate-1.0.0/config/locales/administrate.pt.yml +31 -0
- data/administrate-1.0.0/config/locales/administrate.ru.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.sl.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.sq.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.sv.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.tr.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.uk.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.vi.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.zh-CN.yml +30 -0
- data/administrate-1.0.0/config/locales/administrate.zh-TW.yml +30 -0
- data/administrate-1.0.0/docs/adding_controllers_without_related_model.md +52 -0
- data/administrate-1.0.0/docs/adding_custom_field_types.md +81 -0
- data/administrate-1.0.0/docs/authentication.md +63 -0
- data/administrate-1.0.0/docs/authorization.md +94 -0
- data/administrate-1.0.0/docs/customizing_attribute_partials.md +56 -0
- data/administrate-1.0.0/docs/customizing_controller_actions.md +109 -0
- data/administrate-1.0.0/docs/customizing_dashboards.md +641 -0
- data/administrate-1.0.0/docs/customizing_page_views.md +143 -0
- data/administrate-1.0.0/docs/extending_administrate.md +27 -0
- data/administrate-1.0.0/docs/getting_started.md +150 -0
- data/administrate-1.0.0/docs/guides/customising_search.md +149 -0
- data/administrate-1.0.0/docs/guides/hiding_dashboards_from_sidebar.md +21 -0
- data/administrate-1.0.0/docs/guides/scoping_has_many_relations.md +27 -0
- data/administrate-1.0.0/docs/guides/switching_templates_with_view_variants.md +45 -0
- data/administrate-1.0.0/docs/guides.md +8 -0
- data/administrate-1.0.0/docs/migrating-to-v1.md +34 -0
- data/administrate-1.0.0/docs/rails_api.md +45 -0
- data/administrate-1.0.0/lib/administrate/base_dashboard.rb +145 -0
- data/administrate-1.0.0/lib/administrate/custom_dashboard.rb +15 -0
- data/administrate-1.0.0/lib/administrate/engine.rb +52 -0
- data/administrate-1.0.0/lib/administrate/field/associative.rb +72 -0
- data/administrate-1.0.0/lib/administrate/field/base.rb +119 -0
- data/administrate-1.0.0/lib/administrate/field/belongs_to.rb +55 -0
- data/administrate-1.0.0/lib/administrate/field/boolean.rb +15 -0
- data/administrate-1.0.0/lib/administrate/field/date.rb +24 -0
- data/administrate-1.0.0/lib/administrate/field/date_time.rb +31 -0
- data/administrate-1.0.0/lib/administrate/field/deferred.rb +59 -0
- data/administrate-1.0.0/lib/administrate/field/email.rb +11 -0
- data/administrate-1.0.0/lib/administrate/field/has_many.rb +140 -0
- data/administrate-1.0.0/lib/administrate/field/has_one.rb +55 -0
- data/administrate-1.0.0/lib/administrate/field/number.rb +46 -0
- data/administrate-1.0.0/lib/administrate/field/password.rb +29 -0
- data/administrate-1.0.0/lib/administrate/field/polymorphic.rb +52 -0
- data/administrate-1.0.0/lib/administrate/field/rich_text.rb +21 -0
- data/administrate-1.0.0/lib/administrate/field/select.rb +44 -0
- data/administrate-1.0.0/lib/administrate/field/string.rb +21 -0
- data/administrate-1.0.0/lib/administrate/field/text.rb +21 -0
- data/administrate-1.0.0/lib/administrate/field/time.rb +20 -0
- data/administrate-1.0.0/lib/administrate/field/url.rb +25 -0
- data/administrate-1.0.0/lib/administrate/generator_helpers.rb +13 -0
- data/administrate-1.0.0/lib/administrate/namespace/resource.rb +28 -0
- data/administrate-1.0.0/lib/administrate/namespace.rb +35 -0
- data/administrate-1.0.0/lib/administrate/not_authorized_error.rb +20 -0
- data/administrate-1.0.0/lib/administrate/order.rb +150 -0
- data/administrate-1.0.0/lib/administrate/page/base.rb +40 -0
- data/administrate-1.0.0/lib/administrate/page/collection.rb +38 -0
- data/administrate-1.0.0/lib/administrate/page/form.rb +36 -0
- data/administrate-1.0.0/lib/administrate/page/show.rb +32 -0
- data/administrate-1.0.0/lib/administrate/page.rb +4 -0
- data/administrate-1.0.0/lib/administrate/resource_resolver.rb +44 -0
- data/administrate-1.0.0/lib/administrate/search.rb +167 -0
- data/administrate-1.0.0/lib/administrate/version.rb +3 -0
- data/administrate-1.0.0/lib/administrate/view_generator.rb +48 -0
- data/administrate-1.0.0/lib/administrate.rb +8 -0
- data/administrate-1.0.0/lib/generators/administrate/dashboard/USAGE +9 -0
- data/administrate-1.0.0/lib/generators/administrate/dashboard/dashboard_generator.rb +168 -0
- data/administrate-1.0.0/lib/generators/administrate/dashboard/templates/controller.rb.erb +46 -0
- data/administrate-1.0.0/lib/generators/administrate/dashboard/templates/dashboard.rb.erb +68 -0
- data/administrate-1.0.0/lib/generators/administrate/field/field_generator.rb +31 -0
- data/administrate-1.0.0/lib/generators/administrate/field/templates/_form.html.erb +6 -0
- data/administrate-1.0.0/lib/generators/administrate/field/templates/_index.html.erb +1 -0
- data/administrate-1.0.0/lib/generators/administrate/field/templates/_show.html.erb +1 -0
- data/administrate-1.0.0/lib/generators/administrate/field/templates/field_object.rb.erb +7 -0
- data/administrate-1.0.0/lib/generators/administrate/install/install_generator.rb +91 -0
- data/administrate-1.0.0/lib/generators/administrate/install/templates/application_controller.rb.erb +21 -0
- data/administrate-1.0.0/lib/generators/administrate/routes/routes_generator.rb +96 -0
- data/administrate-1.0.0/lib/generators/administrate/routes/templates/routes.rb.erb +5 -0
- data/administrate-1.0.0/lib/generators/administrate/test_record.rb +21 -0
- data/administrate-1.0.0/lib/generators/administrate/views/edit_generator.rb +16 -0
- data/administrate-1.0.0/lib/generators/administrate/views/field_generator.rb +50 -0
- data/administrate-1.0.0/lib/generators/administrate/views/form_generator.rb +15 -0
- data/administrate-1.0.0/lib/generators/administrate/views/index_generator.rb +21 -0
- data/administrate-1.0.0/lib/generators/administrate/views/layout_generator.rb +24 -0
- data/administrate-1.0.0/lib/generators/administrate/views/navigation_generator.rb +15 -0
- data/administrate-1.0.0/lib/generators/administrate/views/new_generator.rb +16 -0
- data/administrate-1.0.0/lib/generators/administrate/views/show_generator.rb +15 -0
- data/administrate-1.0.0/lib/generators/administrate/views/views_generator.rb +15 -0
- data/administrate-1.0.0/lib/tasks/administrate_tasks.rake +4 -0
- data/mini-max-mod.gemspec +12 -0
- metadata +252 -0
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
pl:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Czy jesteś pewien?
|
|
6
|
+
destroy: Usuń
|
|
7
|
+
edit: Edytuj
|
|
8
|
+
edit_resource: Edytuj %{name}
|
|
9
|
+
show_resource: Wyświetl %{name}
|
|
10
|
+
new_resource: Nowy %{name}
|
|
11
|
+
back: Wstecz
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "Zasób %{resource} został pomyślnie utworzony."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "Zasób %{resource} został pomyślnie usunięty."
|
|
17
|
+
update:
|
|
18
|
+
success: "Zasób %{resource} został pomyślnie zaktualizowany."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: Wyświetlanie %{count} z %{total_count}
|
|
22
|
+
none: Brak
|
|
23
|
+
form:
|
|
24
|
+
error: error
|
|
25
|
+
errors: "%{pluralized_errors} prohibited this %{resource_name} from being saved:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Powrót do aplikacji
|
|
28
|
+
search:
|
|
29
|
+
clear: Wyczyść wyszukiwanie
|
|
30
|
+
label: Szukanie %{resource}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
---
|
|
3
|
+
pt-BR:
|
|
4
|
+
administrate:
|
|
5
|
+
actions:
|
|
6
|
+
confirm: Você tem certeza?
|
|
7
|
+
destroy: Deletar
|
|
8
|
+
edit: Editar
|
|
9
|
+
edit_resource: Editar %{name}
|
|
10
|
+
show_resource: Visualizar %{name}
|
|
11
|
+
new_resource: Criar %{name}
|
|
12
|
+
back: Voltar
|
|
13
|
+
controller:
|
|
14
|
+
create:
|
|
15
|
+
success: "%{resource} foi criado com sucesso."
|
|
16
|
+
destroy:
|
|
17
|
+
success: "%{resource} foi deletado com sucesso."
|
|
18
|
+
update:
|
|
19
|
+
success: "%{resource} foi atualizado com sucesso."
|
|
20
|
+
fields:
|
|
21
|
+
has_many:
|
|
22
|
+
more: "Exibindo %{count} de %{total_count}"
|
|
23
|
+
none: Nenhum
|
|
24
|
+
form:
|
|
25
|
+
error: erro
|
|
26
|
+
errors: "%{pluralized_errors} impediram %{resource_name} de ser gravado:"
|
|
27
|
+
navigation:
|
|
28
|
+
back_to_app: Voltar ao aplicativo
|
|
29
|
+
search:
|
|
30
|
+
clear: Limpar pesquisa
|
|
31
|
+
label: Pesquisa %{resource}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# encoding: UTF-8
|
|
2
|
+
---
|
|
3
|
+
pt:
|
|
4
|
+
administrate:
|
|
5
|
+
actions:
|
|
6
|
+
confirm: Tem certeza?
|
|
7
|
+
destroy: Remover
|
|
8
|
+
edit: Editar
|
|
9
|
+
edit_resource: Editar %{name}
|
|
10
|
+
show_resource: Visualizar %{name}
|
|
11
|
+
new_resource: Novo %{name}
|
|
12
|
+
back: Voltar atrás
|
|
13
|
+
controller:
|
|
14
|
+
create:
|
|
15
|
+
success: "%{resource} foi criado com sucesso."
|
|
16
|
+
destroy:
|
|
17
|
+
success: "%{resource} foi removido com sucesso."
|
|
18
|
+
update:
|
|
19
|
+
success: "%{resource} foi actualizado com sucesso."
|
|
20
|
+
fields:
|
|
21
|
+
has_many:
|
|
22
|
+
more: "Mostrando %{count} de %{total_count}"
|
|
23
|
+
none: Nenhum
|
|
24
|
+
form:
|
|
25
|
+
error: erro
|
|
26
|
+
errors: "%{pluralized_errors} impediram %{resource_name} de ser gravado:"
|
|
27
|
+
navigation:
|
|
28
|
+
back_to_app: Voltar à aplicação
|
|
29
|
+
search:
|
|
30
|
+
clear: Limpar pesquisa
|
|
31
|
+
label: Pesquisa %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
ru:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Вы уверены?
|
|
6
|
+
destroy: Удалить
|
|
7
|
+
edit: Редактировать
|
|
8
|
+
edit_resource: Редактировать %{name}
|
|
9
|
+
show_resource: Показать %{name}
|
|
10
|
+
new_resource: Новый %{name}
|
|
11
|
+
back: Вернуться назад
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} был успешно создан."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} был успешно удален."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} был успешно обновлен."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: "%{count} из %{total_count}"
|
|
22
|
+
none: Нет
|
|
23
|
+
form:
|
|
24
|
+
error: Ошибка
|
|
25
|
+
errors: "При сохранении %{resource_name} произошли ошибки:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Вернуться в приложение
|
|
28
|
+
search:
|
|
29
|
+
clear: Очистить поиск
|
|
30
|
+
label: Поиск %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
sl:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Ali ste preričani?
|
|
6
|
+
destroy: Izbriši
|
|
7
|
+
edit: Uredi
|
|
8
|
+
edit_resource: Uredi %{name}
|
|
9
|
+
show_resource: Prikaži %{name}
|
|
10
|
+
new_resource: Dodaj %{name}
|
|
11
|
+
back: Nazaj
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} je dodan."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} je izbrisan."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} je posodobljen."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: Prikazanih %{count} od %{total_count}
|
|
22
|
+
none: Nobene
|
|
23
|
+
form:
|
|
24
|
+
error: napaka
|
|
25
|
+
errors: "%{resource_name} ni mogoče shraniti zaradi:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Nazaj v aplikacijo
|
|
28
|
+
search:
|
|
29
|
+
clear: Počisti iskanje
|
|
30
|
+
label: Išči %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
sq:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: A jeni te sigurtë?
|
|
6
|
+
destroy: Fshij
|
|
7
|
+
edit: Ndrysho
|
|
8
|
+
edit_resource: Ndrysho %{name}
|
|
9
|
+
show_resource: Trego %{name}
|
|
10
|
+
new_resource: Të re %{name}
|
|
11
|
+
back: Prapa
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} është krijuar me sukses."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} është fshirë me sukses."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} është azhurnuar me sukses."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: Duke treguar %{count} nga %{total_count}
|
|
22
|
+
none: Asnjë
|
|
23
|
+
form:
|
|
24
|
+
error: gabim
|
|
25
|
+
errors: "%{pluralized_errors} nuk e lejoj %{resource_name} të ruhet:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Kthehu tek aplikacioni
|
|
28
|
+
search:
|
|
29
|
+
clear: Pastro kërkimin
|
|
30
|
+
label: Kërko %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
sv:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Är du säker?
|
|
6
|
+
destroy: Ta bort
|
|
7
|
+
edit: Ändra
|
|
8
|
+
edit_resource: Ändra %{name}
|
|
9
|
+
show_resource: Visa %{name}
|
|
10
|
+
new_resource: Ny %{name}
|
|
11
|
+
back: Tillbaka
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} har skapats."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} har tagits bort."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} har uppdaterats."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: "%{count} av %{total_count}"
|
|
22
|
+
none: Inga
|
|
23
|
+
form:
|
|
24
|
+
error: error
|
|
25
|
+
errors: "%{pluralized_errors} prohibited this %{resource_name} from being saved:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Tillbaka till appen
|
|
28
|
+
search:
|
|
29
|
+
clear: Rensa sökningen
|
|
30
|
+
label: Sök %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
tr:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Emin misiniz?
|
|
6
|
+
destroy: Sil
|
|
7
|
+
edit: Düzenle
|
|
8
|
+
edit_resource: "%{name} Kaydını Düzenle"
|
|
9
|
+
show_resource: "%{name} Kaydını Göster"
|
|
10
|
+
new_resource: Yeni %{name}
|
|
11
|
+
back: Geri
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} kaydı başarıyla yaratıldı."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} kaydı başarıyla silindi."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} kaydı başarıyla düzenlendi."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: Toplam %{total_count} kayıttan %{count} adedi gösteriliyor
|
|
22
|
+
none: Yok
|
|
23
|
+
form:
|
|
24
|
+
error: Hata
|
|
25
|
+
errors: "%{resource_name} kaydedilemedi: %{pluralized_errors}"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Uygulamaya geri dön
|
|
28
|
+
search:
|
|
29
|
+
clear: Temizle
|
|
30
|
+
label: "%{resource} içerisinde ara"
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
uk:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Ви впевнені?
|
|
6
|
+
destroy: Видалити
|
|
7
|
+
edit: Редагувати
|
|
8
|
+
edit_resource: Редагувати %{name}
|
|
9
|
+
show_resource: Показати %{name}
|
|
10
|
+
new_resource: Новий %{name}
|
|
11
|
+
back: Назад
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "Успішно створено %{resource}."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "Успішно видалено %{resource}."
|
|
17
|
+
update:
|
|
18
|
+
success: "Успішно оновлено %{resource}."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: "%{count} із %{total_count}"
|
|
22
|
+
none: Немає
|
|
23
|
+
form:
|
|
24
|
+
error: error
|
|
25
|
+
errors: "%{pluralized_errors} prohibited this %{resource_name} from being saved:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Повернутися до програми
|
|
28
|
+
search:
|
|
29
|
+
clear: Очистити пошук
|
|
30
|
+
label: пошук %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
vi:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: Bạn có chắc không?
|
|
6
|
+
destroy: Xóa
|
|
7
|
+
edit: Sửa
|
|
8
|
+
edit_resource: Sửa %{name}
|
|
9
|
+
show_resource: Xem %{name}
|
|
10
|
+
new_resource: Mới %{name}
|
|
11
|
+
back: Trở lại
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} đã được tạo thành công."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} đã được xóa thành công."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} đã được cập nhật thành công."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: "%{count} trên %{total_count}"
|
|
22
|
+
none: Không
|
|
23
|
+
form:
|
|
24
|
+
error: error
|
|
25
|
+
errors: "%{pluralized_errors} prohibited this %{resource_name} from being saved:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: Quay lại ứng dụng
|
|
28
|
+
search:
|
|
29
|
+
clear: Tìm kiếm rõ ràng
|
|
30
|
+
label: Tìm kiếm %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
zh-CN:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: 确定?
|
|
6
|
+
destroy: 删除
|
|
7
|
+
edit: 编辑
|
|
8
|
+
edit_resource: 编辑 %{name}
|
|
9
|
+
show_resource: 查看 %{name}
|
|
10
|
+
new_resource: 新建 %{name}
|
|
11
|
+
back: 返回
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "%{resource} 创建成功."
|
|
15
|
+
destroy:
|
|
16
|
+
success: "%{resource} 删除成功."
|
|
17
|
+
update:
|
|
18
|
+
success: "%{resource} 更新成功."
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: 显示所有 %{total_count} 中 %{count} 条
|
|
22
|
+
none: 无
|
|
23
|
+
form:
|
|
24
|
+
error: 错误
|
|
25
|
+
errors: "%{resource_name} 保存前出现了 %{pluralized_errors} 个错误:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: 返回应用
|
|
28
|
+
search:
|
|
29
|
+
clear: 清除搜索
|
|
30
|
+
label: 搜索 %{resource}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
---
|
|
2
|
+
zh-TW:
|
|
3
|
+
administrate:
|
|
4
|
+
actions:
|
|
5
|
+
confirm: 確定?
|
|
6
|
+
destroy: 刪除
|
|
7
|
+
edit: 編輯
|
|
8
|
+
edit_resource: 編輯 %{name}
|
|
9
|
+
show_resource: 檢視 %{name}
|
|
10
|
+
new_resource: 新增 %{name}
|
|
11
|
+
back: 返回
|
|
12
|
+
controller:
|
|
13
|
+
create:
|
|
14
|
+
success: "已成功新增 %{resource}。"
|
|
15
|
+
destroy:
|
|
16
|
+
success: "已成功刪除 %{resource}。"
|
|
17
|
+
update:
|
|
18
|
+
success: "已成功更新 %{resource}。"
|
|
19
|
+
fields:
|
|
20
|
+
has_many:
|
|
21
|
+
more: 顯示 %{total_count} 筆中的 %{count} 筆資料
|
|
22
|
+
none: 無
|
|
23
|
+
form:
|
|
24
|
+
error: 錯誤
|
|
25
|
+
errors: "%{pluralized_errors} 導致此 %{resource_name} 不能被儲存:"
|
|
26
|
+
navigation:
|
|
27
|
+
back_to_app: 返回首頁
|
|
28
|
+
search:
|
|
29
|
+
clear: 清除搜尋
|
|
30
|
+
label: 搜尋 %{resource}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Adding Controllers without a related Model
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Sometimes you may want to add a custom controller that has no resource
|
|
6
|
+
related to it (for example for a statistics page).
|
|
7
|
+
|
|
8
|
+
To do that, you must define an `index` route, as only controllers with index
|
|
9
|
+
routes are displayed in the sidebar and then add a custom dashboard:
|
|
10
|
+
|
|
11
|
+
```erb
|
|
12
|
+
# app/views/admin/stats/index.html.erb
|
|
13
|
+
|
|
14
|
+
<div style="padding: 20px">
|
|
15
|
+
<h1>Stats</h1>
|
|
16
|
+
<br>
|
|
17
|
+
<p><b>Total Customers:</b> <%= @stats[:customer_count] %></p>
|
|
18
|
+
<br>
|
|
19
|
+
<p><b>Total Orders:</b> <%= @stats[:order_count] %></p>
|
|
20
|
+
</div>
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```ruby
|
|
24
|
+
# app/dashboards/stat_dashboard.rb
|
|
25
|
+
require "administrate/custom_dashboard"
|
|
26
|
+
|
|
27
|
+
class StatDashboard < Administrate::CustomDashboard
|
|
28
|
+
resource "Stats" # used by administrate in the views
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
```ruby
|
|
33
|
+
# app/controllers/admin/stats_controller.rb
|
|
34
|
+
module Admin
|
|
35
|
+
class StatsController < Admin::ApplicationController
|
|
36
|
+
def index
|
|
37
|
+
@stats = {
|
|
38
|
+
customer_count: Customer.count,
|
|
39
|
+
order_count: Order.count,
|
|
40
|
+
}
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
```ruby
|
|
47
|
+
# config/routes.rb
|
|
48
|
+
namespace :admin do
|
|
49
|
+
# ...
|
|
50
|
+
resources :stats, only: [:index]
|
|
51
|
+
end
|
|
52
|
+
```
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Adding Custom Field Types
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
If your application deals with a nonstandard data type,
|
|
6
|
+
you can create an `Administrate::Field` object to help display
|
|
7
|
+
the custom data type across the dashboard.
|
|
8
|
+
|
|
9
|
+
`Administrate::Field` objects consist of two parts:
|
|
10
|
+
a Ruby class and associated views.
|
|
11
|
+
|
|
12
|
+
For example, let's create a `Field` that displays [Gravatars] based on an email.
|
|
13
|
+
|
|
14
|
+
[Gravatars]: https://gravatar.com/
|
|
15
|
+
|
|
16
|
+
First, we'll run a generator to set us up with the files we need:
|
|
17
|
+
|
|
18
|
+
```bash
|
|
19
|
+
rails generate administrate:field gravatar
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
This creates a few files:
|
|
23
|
+
|
|
24
|
+
- `app/fields/gravatar_field.rb`
|
|
25
|
+
- `app/views/fields/gravatar_field/_show.html.erb`
|
|
26
|
+
- `app/views/fields/gravatar_field/_index.html.erb`
|
|
27
|
+
- `app/views/fields/gravatar_field/_form.html.erb`
|
|
28
|
+
|
|
29
|
+
We can edit the `app/fields/gravatar_field.rb` to add some custom logic:
|
|
30
|
+
|
|
31
|
+
```ruby
|
|
32
|
+
# app/fields/gravatar_field.rb
|
|
33
|
+
require 'digest/md5'
|
|
34
|
+
|
|
35
|
+
class GravatarField < Administrate::Field::Base
|
|
36
|
+
def gravatar_url
|
|
37
|
+
email_address = data.downcase
|
|
38
|
+
hash = Digest::MD5.hexdigest(email_address)
|
|
39
|
+
"http://www.gravatar.com/avatar/#{hash}"
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
Next, we can customize the partials to display data how we'd like.
|
|
45
|
+
Open up the `app/views/fields/gravatar_field/_show.html.erb` partial.
|
|
46
|
+
By default, it looks like:
|
|
47
|
+
|
|
48
|
+
```eruby
|
|
49
|
+
<%= field.to_s %>
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Since we want to display an image, we can change it to:
|
|
53
|
+
|
|
54
|
+
```eruby
|
|
55
|
+
<%= image_tag field.gravatar_url %>
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
You can customize the other generated partials in the same way
|
|
59
|
+
for custom behavior on the index and form pages.
|
|
60
|
+
|
|
61
|
+
## Using your custom field
|
|
62
|
+
|
|
63
|
+
We need to tell Administrate which attributes we'd like to be displayed as a
|
|
64
|
+
gravatar image.
|
|
65
|
+
|
|
66
|
+
Open up a dashboard file, and add the gravatar field into the `ATTRIBUTE_TYPES`
|
|
67
|
+
hash. It should look something like:
|
|
68
|
+
|
|
69
|
+
```ruby
|
|
70
|
+
class UserDashboard < Administrate::BaseDashboard
|
|
71
|
+
ATTRIBUTE_TYPES = {
|
|
72
|
+
created_at: Field::DateTime,
|
|
73
|
+
updated_at: Field::DateTime,
|
|
74
|
+
name: Field::String,
|
|
75
|
+
email: GravatarField, # Update this email to use your new field class
|
|
76
|
+
# ...
|
|
77
|
+
}
|
|
78
|
+
end
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
[Customizing Attribute Partials]: /customizing_attribute_partials
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Authenticating admin users
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
Authentication is left for you to implement after you install Administrate into
|
|
6
|
+
your app. It's expected that you can plugin your existing authentication
|
|
7
|
+
system.
|
|
8
|
+
|
|
9
|
+
The base `Admin::ApplicationController` has a `TODO` to be completed:
|
|
10
|
+
|
|
11
|
+
```ruby
|
|
12
|
+
class Admin::ApplicationController < Administrate::ApplicationController
|
|
13
|
+
before_action :authenticate_admin
|
|
14
|
+
|
|
15
|
+
def authenticate_admin
|
|
16
|
+
# TODO Add authentication logic here.
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Using Clearance
|
|
22
|
+
|
|
23
|
+
[Clearance][clearance] provides Rails authentication with email & password.
|
|
24
|
+
|
|
25
|
+
```ruby
|
|
26
|
+
class Admin::ApplicationController < Administrate::ApplicationController
|
|
27
|
+
include Clearance::Controller
|
|
28
|
+
before_action :require_login
|
|
29
|
+
end
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
## Using Devise
|
|
33
|
+
|
|
34
|
+
[Devise][devise] is an authentication solution for Rails with Warden. Include
|
|
35
|
+
the authentication method for your model as a `before_action`:
|
|
36
|
+
|
|
37
|
+
```ruby
|
|
38
|
+
class Admin::ApplicationController < Administrate::ApplicationController
|
|
39
|
+
before_action :authenticate_user!
|
|
40
|
+
end
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Using HTTP Basic authentication
|
|
44
|
+
|
|
45
|
+
Rails includes the [`http_basic_authenticate_with`][rails-http-basic-auth]
|
|
46
|
+
method which can be added to your base admin controller:
|
|
47
|
+
|
|
48
|
+
```ruby
|
|
49
|
+
class Admin::ApplicationController < Administrate::ApplicationController
|
|
50
|
+
http_basic_authenticate_with(
|
|
51
|
+
name: ENV.fetch("ADMIN_NAME"),
|
|
52
|
+
password: ENV.fetch("ADMIN_PASSWORD")
|
|
53
|
+
)
|
|
54
|
+
end
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
With this approach consider using [dotenv][dotenv] to setup your environment and
|
|
58
|
+
avoid committing secrets in your repository.
|
|
59
|
+
|
|
60
|
+
[clearance]: https://github.com/thoughtbot/clearance
|
|
61
|
+
[devise]: https://github.com/plataformatec/devise
|
|
62
|
+
[rails-http-basic-auth]: http://api.rubyonrails.org/classes/ActionController/HttpAuthentication/Basic.html
|
|
63
|
+
[dotenv]: https://github.com/bkeepers/dotenv
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
---
|
|
2
|
+
title: Authorization
|
|
3
|
+
---
|
|
4
|
+
|
|
5
|
+
The default configuration of Administrate is "authenticate-only" - once a
|
|
6
|
+
user is authenticated, that user has access to every action of every object.
|
|
7
|
+
|
|
8
|
+
You can add more fine-grained authorization by overriding methods in the
|
|
9
|
+
controller.
|
|
10
|
+
|
|
11
|
+
## Using Pundit
|
|
12
|
+
|
|
13
|
+
If your app already uses [Pundit](https://github.com/elabs/pundit) for
|
|
14
|
+
authorization, you just need to add one line to your
|
|
15
|
+
`Admin::ApplicationController`:
|
|
16
|
+
|
|
17
|
+
```ruby
|
|
18
|
+
include Administrate::Punditize
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
This will use all the policies from your main app to determine if the
|
|
22
|
+
current user is able to view a given record or perform a given action.
|
|
23
|
+
|
|
24
|
+
### Further limiting scope
|
|
25
|
+
|
|
26
|
+
You may want to limit the scope for a given user beyond what they
|
|
27
|
+
technically have access to see in the main app. For example, a user may
|
|
28
|
+
have all public records in their scope, but you want to only show *their*
|
|
29
|
+
records in the admin interface to reduce confusion.
|
|
30
|
+
|
|
31
|
+
In this case, you can add additional pundit `policy_namespace` in your controller
|
|
32
|
+
and Administrate will use the namespaced pundit policy instead.
|
|
33
|
+
|
|
34
|
+
For example:
|
|
35
|
+
|
|
36
|
+
```ruby
|
|
37
|
+
# app/controllers/admin/posts_controller.rb
|
|
38
|
+
module Admin
|
|
39
|
+
class PostsController < ApplicationController
|
|
40
|
+
include Administrate::Punditize
|
|
41
|
+
|
|
42
|
+
def policy_namespace
|
|
43
|
+
[:admin]
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
end
|
|
47
|
+
|
|
48
|
+
# app/policies/admin/post_policy.rb
|
|
49
|
+
module Admin
|
|
50
|
+
class PostPolicy < ApplicationPolicy
|
|
51
|
+
class Scope < Scope
|
|
52
|
+
def resolve
|
|
53
|
+
scope.where(owner: user)
|
|
54
|
+
end
|
|
55
|
+
end
|
|
56
|
+
end
|
|
57
|
+
end
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Authorization without Pundit
|
|
61
|
+
|
|
62
|
+
Pundit is not necessary to implement authorization within Administrate. It is
|
|
63
|
+
simply a common solution that many in the community use, and for this reason
|
|
64
|
+
Administrate provides a plugin to work with it. However you can use a different
|
|
65
|
+
solution or roll out your own.
|
|
66
|
+
|
|
67
|
+
To integrate a different authorization solution, you will need to
|
|
68
|
+
implement some methods in `Admin::ApplicationController`
|
|
69
|
+
or its subclasses.
|
|
70
|
+
|
|
71
|
+
These are the methods to override, with examples:
|
|
72
|
+
|
|
73
|
+
```ruby
|
|
74
|
+
# Used in listings, such as the `index` actions. It
|
|
75
|
+
# restricts the scope of records that a user can access.
|
|
76
|
+
# Returns an ActiveRecord scope.
|
|
77
|
+
def scoped_resource
|
|
78
|
+
super.where(user: current_user)
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# Return true if the current user can access the given
|
|
82
|
+
# resource, false otherwise.
|
|
83
|
+
def authorized_action?(resource, action)
|
|
84
|
+
current_user.can?(resource, action)
|
|
85
|
+
end
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Additionally, the method `authorize_resource(resource)`
|
|
89
|
+
should throw an exception if the current user is not
|
|
90
|
+
allowed to access the given resource. Normally
|
|
91
|
+
you wouldn't need to override it, as the default
|
|
92
|
+
implementation uses `authorized_action?` to produce the
|
|
93
|
+
correct behaviour. However you may still want to override it
|
|
94
|
+
if you want to raise a custom error type.
|