godmin 0.9.0

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.
Files changed (125) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +24 -0
  3. data/.hound.yml +2 -0
  4. data/.rubocop.yml +7 -0
  5. data/.travis.yml +7 -0
  6. data/Gemfile +11 -0
  7. data/MIT-LICENSE +20 -0
  8. data/README.md +523 -0
  9. data/Rakefile +34 -0
  10. data/app/assets/images/godmin/.keep +0 -0
  11. data/app/assets/javascripts/godmin/application.js +19 -0
  12. data/app/assets/javascripts/godmin/batch_actions.js +42 -0
  13. data/app/assets/javascripts/godmin/navigation.js +9 -0
  14. data/app/assets/javascripts/godmin/select_tags.js +8 -0
  15. data/app/assets/stylesheets/godmin/application.css.scss +62 -0
  16. data/app/views/godmin/application/welcome.html.erb +65 -0
  17. data/app/views/godmin/resource/_actions.html.erb +10 -0
  18. data/app/views/godmin/resource/_batch_actions.html.erb +12 -0
  19. data/app/views/godmin/resource/_breadcrumb.html.erb +21 -0
  20. data/app/views/godmin/resource/_errors.html.erb +9 -0
  21. data/app/views/godmin/resource/_filters.html.erb +23 -0
  22. data/app/views/godmin/resource/_form.html.erb +12 -0
  23. data/app/views/godmin/resource/_pagination.html.erb +6 -0
  24. data/app/views/godmin/resource/_scopes.html.erb +11 -0
  25. data/app/views/godmin/resource/_table.html.erb +36 -0
  26. data/app/views/godmin/resource/columns/_actions.html.erb +11 -0
  27. data/app/views/godmin/resource/edit.html.erb +5 -0
  28. data/app/views/godmin/resource/index.html.erb +17 -0
  29. data/app/views/godmin/resource/new.html.erb +5 -0
  30. data/app/views/godmin/resource/show.html.erb +1 -0
  31. data/app/views/godmin/sessions/new.html.erb +9 -0
  32. data/app/views/godmin/shared/_navigation.html.erb +29 -0
  33. data/app/views/kaminari/_first_page.html.erb +3 -0
  34. data/app/views/kaminari/_gap.html.erb +3 -0
  35. data/app/views/kaminari/_last_page.html.erb +3 -0
  36. data/app/views/kaminari/_next_page.html.erb +3 -0
  37. data/app/views/kaminari/_page.html.erb +3 -0
  38. data/app/views/kaminari/_paginator.html.erb +15 -0
  39. data/app/views/kaminari/_prev_page.html.erb +3 -0
  40. data/app/views/layouts/godmin/_content.html.erb +13 -0
  41. data/app/views/layouts/godmin/_layout.html.erb +13 -0
  42. data/app/views/layouts/godmin/application.html.erb +17 -0
  43. data/app/views/layouts/godmin/login.html.erb +18 -0
  44. data/bin/rails +8 -0
  45. data/config/locales/en.yml +41 -0
  46. data/config/locales/sv.yml +41 -0
  47. data/config/routes.rb +2 -0
  48. data/godmin.gemspec +32 -0
  49. data/lib/generators/godmin/authentication/authentication_generator.rb +61 -0
  50. data/lib/generators/godmin/install/install_generator.rb +34 -0
  51. data/lib/generators/godmin/policy/policy_generator.rb +29 -0
  52. data/lib/generators/godmin/resource/resource_generator.rb +56 -0
  53. data/lib/godmin.rb +24 -0
  54. data/lib/godmin/application.rb +37 -0
  55. data/lib/godmin/authentication.rb +35 -0
  56. data/lib/godmin/authentication/sessions.rb +45 -0
  57. data/lib/godmin/authentication/user.rb +27 -0
  58. data/lib/godmin/authorization.rb +30 -0
  59. data/lib/godmin/authorization/policy.rb +40 -0
  60. data/lib/godmin/authorization/policy_finder.rb +28 -0
  61. data/lib/godmin/engine.rb +4 -0
  62. data/lib/godmin/generators/base.rb +13 -0
  63. data/lib/godmin/helpers/application.rb +6 -0
  64. data/lib/godmin/helpers/batch_actions.rb +17 -0
  65. data/lib/godmin/helpers/filters.rb +108 -0
  66. data/lib/godmin/helpers/tables.rb +41 -0
  67. data/lib/godmin/helpers/translations.rb +19 -0
  68. data/lib/godmin/rails.rb +36 -0
  69. data/lib/godmin/resolver.rb +46 -0
  70. data/lib/godmin/resource.rb +126 -0
  71. data/lib/godmin/resource/batch_actions.rb +45 -0
  72. data/lib/godmin/resource/filters.rb +41 -0
  73. data/lib/godmin/resource/ordering.rb +25 -0
  74. data/lib/godmin/resource/pagination.rb +11 -0
  75. data/lib/godmin/resource/scopes.rb +49 -0
  76. data/lib/godmin/version.rb +3 -0
  77. data/lib/tasks/godmin_tasks.rake +4 -0
  78. data/test/dummy/README.rdoc +28 -0
  79. data/test/dummy/Rakefile +6 -0
  80. data/test/dummy/app/assets/images/.keep +0 -0
  81. data/test/dummy/app/assets/javascripts/application.js +13 -0
  82. data/test/dummy/app/assets/stylesheets/application.css +13 -0
  83. data/test/dummy/app/controllers/application_controller.rb +5 -0
  84. data/test/dummy/app/controllers/concerns/.keep +0 -0
  85. data/test/dummy/app/helpers/application_helper.rb +2 -0
  86. data/test/dummy/app/mailers/.keep +0 -0
  87. data/test/dummy/app/models/.keep +0 -0
  88. data/test/dummy/app/models/concerns/.keep +0 -0
  89. data/test/dummy/app/views/layouts/application.html.erb +14 -0
  90. data/test/dummy/bin/bundle +3 -0
  91. data/test/dummy/bin/rails +4 -0
  92. data/test/dummy/bin/rake +4 -0
  93. data/test/dummy/config.ru +4 -0
  94. data/test/dummy/config/application.rb +23 -0
  95. data/test/dummy/config/boot.rb +5 -0
  96. data/test/dummy/config/database.yml +25 -0
  97. data/test/dummy/config/environment.rb +5 -0
  98. data/test/dummy/config/environments/development.rb +29 -0
  99. data/test/dummy/config/environments/production.rb +80 -0
  100. data/test/dummy/config/environments/test.rb +36 -0
  101. data/test/dummy/config/initializers/backtrace_silencers.rb +7 -0
  102. data/test/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  103. data/test/dummy/config/initializers/inflections.rb +16 -0
  104. data/test/dummy/config/initializers/mime_types.rb +5 -0
  105. data/test/dummy/config/initializers/secret_token.rb +12 -0
  106. data/test/dummy/config/initializers/session_store.rb +3 -0
  107. data/test/dummy/config/initializers/wrap_parameters.rb +14 -0
  108. data/test/dummy/config/locales/en.yml +23 -0
  109. data/test/dummy/config/routes.rb +4 -0
  110. data/test/dummy/db/test.sqlite3 +0 -0
  111. data/test/dummy/lib/assets/.keep +0 -0
  112. data/test/dummy/public/404.html +58 -0
  113. data/test/dummy/public/422.html +58 -0
  114. data/test/dummy/public/500.html +57 -0
  115. data/test/dummy/public/favicon.ico +0 -0
  116. data/test/godmin_test.rb +7 -0
  117. data/test/integration/navigation_test.rb +10 -0
  118. data/test/lib/godmin/policy_finder_test.rb +30 -0
  119. data/test/lib/godmin/resolver_test.rb +31 -0
  120. data/test/test_helper.rb +21 -0
  121. data/vendor/assets/images/godmin/chosen-sprite.png +0 -0
  122. data/vendor/assets/images/godmin/chosen-sprite@2x.png +0 -0
  123. data/vendor/assets/javascripts/.keep +0 -0
  124. data/vendor/assets/stylesheets/.keep +0 -0
  125. metadata +361 -0
@@ -0,0 +1,5 @@
1
+ <%= render partial: "breadcrumb", locals: { index: false } %>
2
+
3
+ <%= render partial: "errors", locals: { errors: @resource.errors } %>
4
+
5
+ <%= render partial: "form" %>
@@ -0,0 +1 @@
1
+ The fate of this page has yet to be determined...
@@ -0,0 +1,9 @@
1
+ <%= simple_form_for(@admin_user, url: session_path) do |f| %>
2
+ <div class="form-group">
3
+ <%= f.input @admin_user.class.login_column, input_html: { class: "form-control" } %>
4
+ </div>
5
+ <div class="form-group">
6
+ <%= f.input :password, input_html: { class: "form-control" } %>
7
+ </div>
8
+ <%= f.submit translate_scoped("sessions.sign_in"), class: "btn btn-block btn-primary" %>
9
+ <% end %>
@@ -0,0 +1,29 @@
1
+ <ul class="nav navbar-nav">
2
+ <% Godmin.resources.each do |resource| %>
3
+ <% unless authorization_enabled? && !policy(resource).index? %>
4
+ <% if controller.controller_name == resource.to_s %>
5
+ <li class="active">
6
+ <% else %>
7
+ <li>
8
+ <% end %>
9
+ <%= link_to resource.to_s.classify.constantize.model_name.human(count: 2), resource %>
10
+ </li>
11
+ <% end %>
12
+ <% end %>
13
+ </ul>
14
+ <ul class="nav navbar-nav navbar-right">
15
+ <% if authentication_enabled? &&
16
+ admin_user.singleton_class.include?(Godmin::Authentication::User) &&
17
+ admin_user_signed_in? %>
18
+ <li class="dropdown">
19
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown">
20
+ <%= admin_user.login %> <span class="caret"></span>
21
+ </a>
22
+ <ul class="dropdown-menu" role="menu">
23
+ <li>
24
+ <%= link_to translate_scoped("sessions.sign_out"), session_path, method: :delete %>
25
+ </li>
26
+ </ul>
27
+ </li>
28
+ <% end %>
29
+ </ul>
@@ -0,0 +1,3 @@
1
+ <li>
2
+ <%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
3
+ </li>
@@ -0,0 +1,3 @@
1
+ <li class="disabled">
2
+ <%= link_to raw(t 'views.pagination.truncate'), '#' %>
3
+ </li>
@@ -0,0 +1,3 @@
1
+ <li>
2
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, :remote => remote %>
3
+ </li>
@@ -0,0 +1,3 @@
1
+ <li>
2
+ <%= link_to_unless current_page.last?, raw(t 'views.pagination.next'), url, :rel => 'next', :remote => remote %>
3
+ </li>
@@ -0,0 +1,3 @@
1
+ <li class="<%= 'active' if page.current? %>">
2
+ <%= link_to page, page.current? ? '#' : url, :remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil %>
3
+ </li>
@@ -0,0 +1,15 @@
1
+ <%= paginator.render do -%>
2
+ <ul class="pagination">
3
+ <%= first_page_tag unless current_page.first? %>
4
+ <%= prev_page_tag unless current_page.first? %>
5
+ <% each_page do |page| -%>
6
+ <% if page.left_outer? || page.right_outer? || page.inside_window? -%>
7
+ <%= page_tag page %>
8
+ <% elsif !page.was_truncated? -%>
9
+ <%= gap_tag %>
10
+ <% end -%>
11
+ <% end -%>
12
+ <%= next_page_tag unless current_page.last? %>
13
+ <%= last_page_tag unless current_page.last? %>
14
+ </ul>
15
+ <% end -%>
@@ -0,0 +1,3 @@
1
+ <li>
2
+ <%= link_to_unless current_page.first?, raw(t 'views.pagination.previous'), url, :rel => 'prev', :remote => remote %>
3
+ </li>
@@ -0,0 +1,13 @@
1
+ <% if flash[:alert] %>
2
+ <div class="alert alert-danger">
3
+ <%= flash[:alert] %>
4
+ </div>
5
+ <% end %>
6
+
7
+ <% if flash[:notice] %>
8
+ <div class="alert alert-info">
9
+ <%= flash[:notice] %>
10
+ </div>
11
+ <% end %>
12
+
13
+ <%= yield %>
@@ -0,0 +1,13 @@
1
+ <!doctype html>
2
+ <html>
3
+ <head>
4
+ <title>Godmin</title>
5
+ <%= stylesheet_link_tag "godmin/application", [Godmin.namespace, "application"].compact.join("/"), media: "all" %>
6
+ <%= javascript_include_tag "godmin/application", [Godmin.namespace, "application"].compact.join("/") %>
7
+ <%= csrf_meta_tags %>
8
+ <%= yield :head %>
9
+ </head>
10
+ <body>
11
+ <%= yield :body %>
12
+ </body>
13
+ </html>
@@ -0,0 +1,17 @@
1
+ <% content_for :body do %>
2
+ <nav class="navbar navbar-default navbar-static-top" role="navigation">
3
+ <div class="container">
4
+ <div class="navbar-header">
5
+ <%= link_to "Godmin", root_path, class: "navbar-brand" %>
6
+ </div>
7
+ <div class="collapse navbar-collapse navbar-ex1-collapse">
8
+ <%= render partial: "shared/navigation" %>
9
+ </div>
10
+ </div>
11
+ </nav>
12
+ <div class="container">
13
+ <%= render "layouts/godmin/content" %>
14
+ </div>
15
+ <% end %>
16
+
17
+ <%= render "layouts/godmin/layout" %>
@@ -0,0 +1,18 @@
1
+ <% content_for :body do %>
2
+ <div id="login" class="container">
3
+ <div class="row">
4
+ <div class="col-md-4 col-md-offset-4">
5
+ <div class="panel panel-default">
6
+ <div class="panel-heading">
7
+ <h3 class="panel-title">Godmin</h3>
8
+ </div>
9
+ <div class="panel-body">
10
+ <%= render "layouts/godmin/content" %>
11
+ </div>
12
+ </div>
13
+ </div>
14
+ </div>
15
+ </div>
16
+ <% end %>
17
+
18
+ <%= render "layouts/godmin/layout" %>
data/bin/rails ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ # This command will automatically be run when you run "rails" with Rails 4 gems installed from the root of your application.
3
+
4
+ ENGINE_ROOT = File.expand_path('../..', __FILE__)
5
+ ENGINE_PATH = File.expand_path('../../lib/godmin/engine', __FILE__)
6
+
7
+ require 'rails/all'
8
+ require 'rails/engine/commands'
@@ -0,0 +1,41 @@
1
+ en:
2
+ godmin:
3
+ batch_actions:
4
+ select_all: Select all
5
+ deselect_all: Deselect all
6
+ confirm_message: Are you sure?
7
+ filters:
8
+ select:
9
+ placeholder:
10
+ one: Select something
11
+ many: Select something
12
+ buttons:
13
+ apply: Filter
14
+ clear: Clear filter
15
+ column_actions:
16
+ show: Show
17
+ edit: Edit
18
+ destroy: Destroy
19
+ confirm_message: Are you sure?
20
+ sessions:
21
+ sign_in: Sign in
22
+ sign_out: Sign out
23
+ signed_in: Signed in
24
+ signed_out: Signed out
25
+ failed_sign_in: Invalid credentials
26
+ views:
27
+ pagination:
28
+ first: "First"
29
+ last: "Last"
30
+ previous: "&laquo;"
31
+ next: "&raquo;"
32
+ truncate: "&hellip;"
33
+ helpers:
34
+ page_entries_info:
35
+ one_page:
36
+ display_entries:
37
+ zero: "No %{entry_name} found"
38
+ one: "Displaying 1 %{entry_name}"
39
+ other: "Displaying all %{count} %{entry_name}"
40
+ more_pages:
41
+ display_entries: "Displaying %{entry_name} %{first}&nbsp;-&nbsp;%{last} of %{total} in total"
@@ -0,0 +1,41 @@
1
+ sv:
2
+ godmin:
3
+ batch_actions:
4
+ select_all: Markera alla
5
+ deselect_all: Avmarkera alla
6
+ confirm_message: Är du säker?
7
+ filters:
8
+ select:
9
+ placeholder:
10
+ one: Välj någonting
11
+ many: Välj någonting
12
+ buttons:
13
+ apply: Filtrera
14
+ clear: Rensa filter
15
+ column_actions:
16
+ show: Visa
17
+ edit: Ändra
18
+ destroy: Ta bort
19
+ confirm_message: Är du säker?
20
+ sessions:
21
+ sign_in: Logga in
22
+ sign_out: Logga ut
23
+ signed_in: Loggade in
24
+ signed_out: Loggade ut
25
+ failed_sign_in: Fel inloggningsuppgifter
26
+ views:
27
+ pagination:
28
+ first: "Första"
29
+ last: "Sista"
30
+ previous: "&laquo;"
31
+ next: "&raquo;"
32
+ truncate: "&hellip;"
33
+ helpers:
34
+ page_entries_info:
35
+ one_page:
36
+ display_entries:
37
+ zero: "Inga %{entry_name} hittades"
38
+ one: "Visar 1 %{entry_name}"
39
+ other: "Visar alla %{count} %{entry_name}"
40
+ more_pages:
41
+ display_entries: "Visar %{first}&nbsp;-&nbsp;%{last} av %{total} %{entry_name}"
data/config/routes.rb ADDED
@@ -0,0 +1,2 @@
1
+ Godmin::Engine.routes.draw do
2
+ end
data/godmin.gemspec ADDED
@@ -0,0 +1,32 @@
1
+ $:.push File.expand_path("../lib", __FILE__)
2
+
3
+ # Maintain your gem's version:
4
+ require "godmin/version"
5
+
6
+ # Describe your gem and declare its dependencies:
7
+ Gem::Specification.new do |gem|
8
+ gem.name = "godmin"
9
+ gem.version = Godmin::VERSION
10
+ gem.authors = ["Jens Ljungblad", "Linus Pettersson", "Varvet"]
11
+ gem.email = ["hej@varvet.se"]
12
+ gem.homepage = "https://github.com/varvet/godmin"
13
+ gem.summary = "Godmin is an admin engine for Rails 4+"
14
+ gem.description = "Godmin is an admin engine for Rails 4+"
15
+ gem.license = "MIT"
16
+
17
+ gem.files = `git ls-files`.split($/)
18
+ gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
19
+ gem.test_files = gem.files.grep(%r{^(test|spec|features)/})
20
+ gem.require_paths = ["lib"]
21
+
22
+ gem.add_dependency "bcrypt", "~> 3.1.7"
23
+ gem.add_dependency "bootstrap-sass", "~> 3.1.1.0"
24
+ gem.add_dependency "coffee-rails", [">= 4.0", "< 4.2"]
25
+ gem.add_dependency "kaminari", "~> 0.16.1"
26
+ gem.add_dependency "rails", [">= 4.0", "< 4.2"]
27
+ gem.add_dependency "sass-rails", [">= 4.0", "< 4.2"]
28
+ gem.add_dependency "select2-rails", "~> 3.5.7"
29
+ gem.add_dependency "simple_form", "~> 3.0.0"
30
+
31
+ gem.add_development_dependency "sqlite3"
32
+ end
@@ -0,0 +1,61 @@
1
+ require "godmin/generators/base"
2
+
3
+ class Godmin::AuthenticationGenerator < Godmin::Generators::Base
4
+ argument :model, type: :string, default: "admin_user"
5
+
6
+ def create_model
7
+ generate "model", "#{@model} email:string password_digest:text --no-test-framework"
8
+ end
9
+
10
+ def modify_model
11
+ inject_into_file ["app/models", namespace, "#{@model.underscore}.rb"].compact.join("/"), after: "ActiveRecord::Base\n" do
12
+ <<-END.strip_heredoc.indent(namespace.nil? ? 2 : 4)
13
+ include Godmin::Authentication::User
14
+
15
+ def self.login_column
16
+ :email
17
+ end
18
+ END
19
+ end
20
+ end
21
+
22
+ def create_route
23
+ inject_into_file "config/routes.rb", after: "godmin do\n" do
24
+ <<-END.strip_heredoc.indent(4)
25
+ resource :session, only: [:new, :create, :destroy]
26
+ END
27
+ end
28
+ end
29
+
30
+ def create_sessions_controller
31
+ create_file ["app/controllers", namespace, "sessions_controller.rb"].compact.join("/") do
32
+ if namespace
33
+ <<-END.strip_heredoc
34
+ module #{namespace.camelize}
35
+ class SessionsController < ApplicationController
36
+ include Godmin::Authentication::Sessions
37
+ end
38
+ end
39
+ END
40
+ else
41
+ <<-END.strip_heredoc
42
+ class SessionsController < ApplicationController
43
+ include Godmin::Authentication::Sessions
44
+ end
45
+ END
46
+ end
47
+ end
48
+ end
49
+
50
+ def modify_application_controller
51
+ inject_into_file ["app/controllers", namespace, "application_controller.rb"].compact.join("/"), after: "Godmin::Application\n" do
52
+ <<-END.strip_heredoc.indent(namespace.nil? ? 2 : 4)
53
+ include Godmin::Authentication
54
+
55
+ def admin_user_class
56
+ #{[namespace, @model.underscore].compact.join("/").camelize}
57
+ end
58
+ END
59
+ end
60
+ end
61
+ end
@@ -0,0 +1,34 @@
1
+ require "godmin/generators/base"
2
+
3
+ class Godmin::InstallGenerator < Godmin::Generators::Base
4
+ def create_initializer
5
+ create_file "config/initializers/godmin.rb" do
6
+ <<-END.strip_heredoc
7
+ Godmin.configure do |config|
8
+ config.namespace = #{namespace ? "\"#{namespace}\"" : "nil"}
9
+ end
10
+ END
11
+ end
12
+ end
13
+
14
+ def create_routes
15
+ inject_into_file "config/routes.rb", before: /^end/ do
16
+ <<-END.strip_heredoc.indent(2)
17
+ godmin do
18
+ end
19
+ END
20
+ end
21
+ end
22
+
23
+ def modify_application_controller
24
+ inject_into_file ["app/controllers", namespace, "application_controller.rb"].compact.join("/"), after: "ActionController::Base\n" do
25
+ <<-END.strip_heredoc.indent(namespace == nil ? 2 : 4)
26
+ include Godmin::Application
27
+ END
28
+ end
29
+ end
30
+
31
+ def remove_layouts
32
+ remove_dir "app/views/layouts"
33
+ end
34
+ end
@@ -0,0 +1,29 @@
1
+ require "godmin/generators/base"
2
+
3
+ class Godmin::PolicyGenerator < Godmin::Generators::Base
4
+ argument :resource, type: :string
5
+
6
+ def create_controller
7
+ create_file ["app/policies", "#{policy_name}.rb"].compact.join("/") do
8
+ if namespace
9
+ <<-END.strip_heredoc
10
+ module #{namespace.camelize}
11
+ class #{@resource.underscore.camelize}Policy < Godmin::Authorization::Policy
12
+ end
13
+ end
14
+ END
15
+ else
16
+ <<-END.strip_heredoc
17
+ class #{@resource.underscore.camelize}Policy < Godmin::Authorization::Policy
18
+ end
19
+ END
20
+ end
21
+ end
22
+ end
23
+
24
+ private
25
+
26
+ def policy_name
27
+ [namespace, "#{@resource.underscore}_policy"].compact.join("/")
28
+ end
29
+ end
@@ -0,0 +1,56 @@
1
+ require "godmin/generators/base"
2
+
3
+ class Godmin::ResourceGenerator < Godmin::Generators::Base
4
+ argument :resource, type: :string
5
+ argument :attributes, type: :array, default: [], banner: "attribute attribute"
6
+
7
+ def create_route
8
+ inject_into_file "config/routes.rb", after: "godmin do\n" do
9
+ <<-END.strip_heredoc.indent(4)
10
+ resources :#{@resource.tableize}
11
+ END
12
+ end
13
+ end
14
+
15
+ def create_controller
16
+ create_file ["app/controllers", "#{controller_name}.rb"].compact.join("/") do
17
+ if namespace
18
+ <<-END.strip_heredoc
19
+ module #{namespace.camelize}
20
+ class #{@resource.tableize.camelize}Controller < ApplicationController
21
+ include Godmin::Resource
22
+
23
+ def attrs_for_index
24
+ #{attributes.map(&:to_sym)}
25
+ end
26
+
27
+ def attrs_for_form
28
+ #{attributes.map(&:to_sym)}
29
+ end
30
+ end
31
+ end
32
+ END
33
+ else
34
+ <<-END.strip_heredoc
35
+ class #{@resource.tableize.camelize}Controller < ApplicationController
36
+ include Godmin::Resource
37
+
38
+ def attrs_for_index
39
+ #{attributes.map(&:to_sym)}
40
+ end
41
+
42
+ def attrs_for_form
43
+ #{attributes.map(&:to_sym)}
44
+ end
45
+ end
46
+ END
47
+ end
48
+ end
49
+ end
50
+
51
+ private
52
+
53
+ def controller_name
54
+ [namespace, "#{@resource.tableize}_controller"].compact.join("/")
55
+ end
56
+ end