rails-admin-scaffold 0.0.3 → 0.0.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 5fda3b7d31f0e59bfd8a87061d58efc5ace00126
4
- data.tar.gz: d2fd5def8bb5d467f08b3333b74ec0d760a2336f
3
+ metadata.gz: 047a213169509ab0db974b913fc14530c4716c75
4
+ data.tar.gz: f76109744f433b3dc6b0a982850c08da660dc240
5
5
  SHA512:
6
- metadata.gz: 2cf73609838640fd2f8a364fb9992478674ecb64669ba814f477706ece4b73f723f8f0a6009f2cb5cb9717ebc80e760abaa634f7780c5abf88243f81b56dc499
7
- data.tar.gz: a3a01114523fe64fee99dbc53f4fdbc6e7280ddfc1be7d735db51eb339ca378a6fd77f202f605e6617ffd1541850cf7047011db14e872498a0628b6d4ccfeb83
6
+ metadata.gz: abde7675f69e06bbbfb77c63c9c3efb9c96d9544acca98f73fb9253812b02efeed512b21c37a73bd3ae8c04e2f188cf9da7fa6b6d3d5ba9e1091317bd8c15219
7
+ data.tar.gz: 3a61f13b18ab97a203d128f7d6b92708b83d45ee01520135ef6d5903a6e2eff859b0e80177a6dc4b546816e26e467141a205a7a6c8bd6bea1095d674180856cf
data/README.md CHANGED
@@ -24,6 +24,18 @@ If you want change the prefix name 'admin' to 'manager' for example you can do s
24
24
 
25
25
  ```bin/rails g admin:scaffold_controller Post title:string content:text published:boolean --prefix_name=manager```
26
26
 
27
+ This will generate `class Manager::PostsController < ApplicationController`
28
+
29
+ #### How to customize your parent controller
30
+
31
+ If you want all your Admin controllers to inherit from another
32
+ controller like `AdminController` you can specify the
33
+ --parent_controller option:
34
+
35
+ ```bin/rails g admin:scaffold_controller Post title:string content:text published:boolean --parent_controller=admin```
36
+
37
+ This will generate `class Admin::PostsController < AdminController`
38
+
27
39
  Supports
28
40
  --------
29
41
  * Rails 4+
@@ -37,7 +49,7 @@ Plans
37
49
  * <del>add jbuilder support</del>
38
50
  * <del>improve tests</del>
39
51
  * <del>use travis for ci</del>
40
- * ability to specify parent controller name (e.g. AdminController instead of ApplicationController)
52
+ * <del>ability to specify parent controller name (e.g. AdminController instead of ApplicationController)</del>
41
53
  * add minitest support
42
54
  * add rspec support
43
55
  * split controller_scaffold into several separate generators
@@ -26,6 +26,9 @@ module Admin
26
26
  class_option :prefix_name, banner: "admin", type: :string, default: "admin",
27
27
  desc: "Define the prefix of controller"
28
28
 
29
+ class_option :parent_controller, banner: "admin", type: :string, default: "application",
30
+ desc: "Define the parent controller"
31
+
29
32
  argument :attributes, type: :array, default: [], banner: "field:type field:type"
30
33
 
31
34
  def initialize(args, *options) #:nodoc:
@@ -90,6 +93,10 @@ module Admin
90
93
  "#{prefix.capitalize}::#{controller_class_name}"
91
94
  end
92
95
 
96
+ def parent_controller_class_name
97
+ options[:parent_controller].capitalize
98
+ end
99
+
93
100
  def prefixed_route_url
94
101
  "/#{prefix}#{route_url}"
95
102
  end
@@ -3,7 +3,7 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
3
3
 
4
4
  <% end -%>
5
5
  <% module_namespacing do -%>
6
- class <%= prefixed_controller_class_name %>Controller < ApplicationController
6
+ class <%= prefixed_controller_class_name %>Controller < <%= parent_controller_class_name %>Controller
7
7
  before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
8
8
 
9
9
  # GET <%= prefixed_route_url %>
@@ -3,7 +3,7 @@ require_dependency "<%= namespaced_file_path %>/application_controller"
3
3
 
4
4
  <% end -%>
5
5
  <% module_namespacing do -%>
6
- class <%= prefixed_controller_class_name %>Controller < ApplicationController
6
+ class <%= prefixed_controller_class_name %>Controller < <%= parent_controller_class_name %>Controller
7
7
  before_action :set_<%= singular_table_name %>, only: [:show, :edit, :update, :destroy]
8
8
 
9
9
  # GET <%= prefixed_route_url %>
@@ -1,3 +1,3 @@
1
1
  module RailsAdminScaffold
2
- VERSION = "0.0.3"
2
+ VERSION = "0.0.4"
3
3
  end
@@ -123,5 +123,10 @@ class Admin::Generators::ScaffoldControllerGeneratorTest < Rails::Generators::Te
123
123
  end
124
124
  end
125
125
 
126
-
126
+ def test_with_parent_controller
127
+ run_generator ["User", "name:string", "age:integer", "--parent_controller=admin"]
128
+ assert_file "app/controllers/admin/users_controller.rb" do |content|
129
+ assert_match(/< AdminController/, content)
130
+ end
131
+ end
127
132
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rails-admin-scaffold
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kirill Kalachev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-04-10 00:00:00.000000000 Z
11
+ date: 2014-05-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails