activeadmin_active_resource 0.1.1 → 0.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 693924c691a6662812b9272be525e0749137b642
4
- data.tar.gz: 7351de5cb82fc67a7acb6cf0ab42f3e81c7e4798
3
+ metadata.gz: 5176bbe601d9aa99e39fceffb8e970d2968daacf
4
+ data.tar.gz: 005f7938c408c007a1cec4f2308445e2e076c22b
5
5
  SHA512:
6
- metadata.gz: b14cee7688627c7865e484161a3b1ccf86ef9c3b8d0f3f6873690647c7454f7c3af2f622a36e7d772b84bc159deee89d80cb6eaaeac6bb624776281790c4eb71
7
- data.tar.gz: eccbba12431224eb4d96c9f36c5de219bdc2b54ade4f505ab951035a5199e6048475307916f27fe19808c36445bcfd290fd75fd84d257253eabb866ede8176bb
6
+ metadata.gz: fa97f8f4b8882a288d5618c71bf5d750ee4a5732b537cef208d23404f483e2089a095f033a2892cb6a0b950a8a05d8d655a3e305f9cc1d5956e4dd0c7b227890
7
+ data.tar.gz: c5419a948a7b0b086cd70e05a0a0b27630bf14eb48323073674e869df0de9bca48809da4b15eb6d97ccc5d90e2535e9dd7690f006a0f65b01b299f54f7a40d3a
data/README.md CHANGED
@@ -1,20 +1,16 @@
1
1
  # ActiveAdmin Active Resource [![Gem Version](https://badge.fury.io/rb/activeadmin_active_resource.svg)](https://badge.fury.io/rb/activeadmin_active_resource)
2
2
 
3
- An Active Admin plugin to use Active Resource.
4
-
5
- Data is fetched from an external API.
3
+ Active Admin + [Active Resource](https://github.com/rails/activeresource): to use a REST API in place of a local database as data source.
6
4
 
7
5
  WARNING: this component is a Beta version, some Active Admin functionalities don't work as expected:
8
6
 
9
- - Batch Action: not supported
10
7
  - Filters: partially supported (see example)
11
8
  - Edit: fields must be configured explicitly
12
9
  - Comments: not supported
13
10
 
14
11
  ## Install
15
12
 
16
- - Add to your Gemfile:
17
- `gem 'activeadmin_active_resource'`
13
+ - Add to your Gemfile: `gem 'activeadmin_active_resource'`
18
14
  - Execute bundle
19
15
  - Disable comments in active_admin config initializer
20
16
 
@@ -24,9 +20,9 @@ WARNING: this component is a Beta version, some Active Admin functionalities don
24
20
 
25
21
  ```rb
26
22
  class Post < ActiveResource::Base
27
- self.site = 'http://localhost:3000'
23
+ self.site = 'http://localhost:3000' # API url: another Rails project, a REST API, etc.
28
24
 
29
- self.schema = {
25
+ self.schema = { # Fields must be declared explicitly
30
26
  id: :integer,
31
27
  title: :string,
32
28
  description: :text,
@@ -45,13 +41,11 @@ end
45
41
 
46
42
  ```rb
47
43
  ActiveAdmin.register Post do
48
- config.batch_actions = false
49
-
50
44
  filter :title_cont # Ransack postfixes required (_eq, _cont, etc.)
51
45
 
52
46
  controller do
53
47
  def permitted_params
54
- params.permit! # Just to make things easier :)
48
+ params.permit! # Permit all just for testing
55
49
  end
56
50
  end
57
51
 
@@ -66,6 +60,8 @@ ActiveAdmin.register Post do
66
60
  end
67
61
  ```
68
62
 
63
+ - Ransack options [here](https://github.com/activerecord-hackery/ransack#search-matchers)
64
+
69
65
  ## Notes
70
66
 
71
67
  If you create a new rails project don't use *--skip-active-record*
@@ -14,6 +14,21 @@ end
14
14
  self.collection_parser = ActiveAdmin::ActiveResource::Results
15
15
 
16
16
  class << self
17
+ prepend( FindExt = Module.new do
18
+ def find( *arguments )
19
+ # First argument an array -> batch action
20
+ if arguments.count > 0 && arguments[0].is_a?( Array )
21
+ ret = []
22
+ arguments[0].each do |id|
23
+ ret << find( id )
24
+ end
25
+ ret.compact
26
+ else
27
+ super
28
+ end
29
+ end
30
+ end )
31
+
17
32
  def _ransackers
18
33
  {}
19
34
  end
@@ -28,12 +43,6 @@ end
28
43
  @columns ||= self.known_attributes.map { |col| OpenStruct.new( name: col ) }
29
44
  end
30
45
 
31
- # -> http://api.rubyonrails.org/classes/ActiveRecord/ConnectionAdapters/SchemaCache.html#method-i-columns_hash
32
- # def columns_hash
33
- # # { 'title' => OpenStruct.new( type: :string ) }
34
- # {}
35
- # end
36
-
37
46
  def find_all( options = {} )
38
47
  prefix_options, query_options = split_options(options[:params])
39
48
  path = collection_path(prefix_options, query_options)
@@ -59,18 +68,11 @@ end
59
68
  def page( page )
60
69
  @page = page.to_i
61
70
  @page = 1 if @page < 1
62
- # results = find_all params: {page: page, per_page: 10, order: @order}
63
- # results.current_page = page ? page.to_i : 1
64
- # results.limit_value = @connection_response['pagination-limit'].to_i
65
- # results.total_count = @connection_response['pagination-totalcount'].to_i
66
- # results.total_pages = ( results.total_count.to_f / results.limit_value ).ceil
67
- # results
68
71
  self
69
72
  end
70
73
 
71
74
  def per( page_count )
72
75
  @page_count = page_count.to_i
73
- # self
74
76
  results
75
77
  end
76
78
 
@@ -1,5 +1,5 @@
1
1
  module ActiveAdmin
2
2
  module ActiveResource
3
- VERSION = '0.1.1'
3
+ VERSION = '0.1.2'
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activeadmin_active_resource
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mattia Roccoberton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-03-03 00:00:00.000000000 Z
11
+ date: 2018-03-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activeadmin