assigns_has_many_through_relations 0.0.11 → 0.0.13

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: 981771fee9e171bbe604017590b61b347209bce5
4
- data.tar.gz: 83d04fdcb7937534b5c8130b8c828348469dcd42
3
+ metadata.gz: 9a9fc7fc5fc04b4256df6bcf9937de2af13bc69c
4
+ data.tar.gz: 7c23464499a37789d47ada70d9c604ef2f574995
5
5
  SHA512:
6
- metadata.gz: 6c4c7b9c221b19462e3e4789dbf4205d0e9b955d5958c21b1add8fea9707a2e5e26484de61f35786b9e8774e62dae6d47f37fdd44228af2c090031b263e265fe
7
- data.tar.gz: 002a6afcf55f3939c7220d25d009b0b4b6fe63d8bb2762a104a91e2f4486a2c117f47d132ec3b2b0c0ab5062f3e81eee78da4dc74621f538f3737d8ae55b125b
6
+ metadata.gz: c8d088693c91dd55f7abed097debf09ff6f493531bc670f642d1a2698b60c904e148a176dd68d1826b23bd1c46becfdb12714a50428298e62f1704fee46c5570
7
+ data.tar.gz: fa2d1bb2a49ab638732571769cbc28d25716fc04c57b37c525ef1278e9deab66283c33ebebb76a3f91bd4e07c3679a363969ea63b0462345bc48aaa33b705006
data/README.md CHANGED
@@ -79,6 +79,11 @@ You'll have to provide the user with a link to `locations_users_path`. And that'
79
79
 
80
80
  **Note:** _currently the left side model has to respond_to `name` for a nice display name, and the right side model has to respond to `full_name`. This will be configurable soon._
81
81
 
82
+ ## JavaScript
83
+ Require assigns_has_many_through_relations in your application.js
84
+ ```js
85
+ //= require 'assigns_has_many_through_relations'
86
+ ```
82
87
  ## Configuration
83
88
 
84
89
  You can configure the engine in an initializer. The given examples are the defaults except for `auth_filter`. That won't run if you don't set it.
@@ -128,7 +133,7 @@ end
128
133
 
129
134
  ## Contributing
130
135
 
131
- 1. Fork it ( https://github.com/[my-github-username]/assigns_has_many_through_relations/fork )
136
+ 1. Fork it ( https://github.com/DiegoSalazar/assigns_has_many_through_relations/fork )
132
137
  2. Create your feature branch (`git checkout -b my-new-feature`)
133
138
  3. Commit your changes (`git commit -am 'Add some feature'`)
134
139
  4. Push to the branch (`git push origin my-new-feature`)
@@ -0,0 +1 @@
1
+ //= require_tree './assigns_has_many_through_relations'
@@ -92,8 +92,8 @@
92
92
  <% @available_right_side_models.each do |model| %>
93
93
  <li>
94
94
  <%= f.fields_for join_name, model.send(join_name).build do |ruf| %>
95
- <%= ruf.check_box "#{model.class.name.demodulize.underscore}_id", { checked: false }, model.id, nil %>
96
- <%= ruf.label "#{model.class.name.demodulize.underscore}_id", model.full_name %>
95
+ <%= ruf.check_box "#{model.class.base_class.name.underscore}_id", { checked: false }, model.id, nil %>
96
+ <%= ruf.label "#{model.class.base_class.name.underscore}_id", model.full_name %>
97
97
  <% end %>
98
98
  </li>
99
99
  <% end %>
@@ -18,7 +18,7 @@ Gem::Specification.new do |spec|
18
18
  spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
19
  spec.require_paths = ["lib"]
20
20
 
21
- spec.add_dependency 'rails', '~> 3'
21
+ spec.add_dependency 'rails', '>= 3'
22
22
 
23
23
  spec.add_development_dependency "bundler", "~> 1.7"
24
24
  spec.add_development_dependency "rake", "~> 10.0"
@@ -33,7 +33,7 @@ module AssignsHasManyThroughRelations
33
33
  right_name = right_relation.to_s.pluralize
34
34
 
35
35
  routes.get "/#{left_name}/#{right_name}/:id", to: "#{name}#index", as: name
36
- routes.put "/#{left_name}/#{right_name}/:id", to: "#{name}#update", as: "assign_#{name}"
36
+ Rails.version.to_i >= 4 ? (routes.patch "/#{left_name}/#{right_name}/:id", to: "#{name}#update", as: "assign_#{name}") : (routes.put "/#{left_name}/#{right_name}/:id", to: "#{name}#update", as: "assign_#{name}")
37
37
  end
38
38
  end
39
39
 
@@ -45,7 +45,7 @@ module AssignsHasManyThroughRelations
45
45
  def update
46
46
  left_side_model = self.class.left_relation_class.find params[:id]
47
47
 
48
- if left_side_model.update_attributes params[self.class.left_relation_param_name]
48
+ if left_side_model.update_attributes defined?(ActionController::StrongParameters) == nil ? params[self.class.left_relation_param_name] : params[self.class.left_relation_param_name].permit!
49
49
  flash[:notice] = "Successfully set #{self.class.left_relation_param_name} assignments"
50
50
  else
51
51
  flash[:error] = left_side_model.errors.full_messages.to_sentence
@@ -6,7 +6,10 @@ module AssignsHasManyThroughRelations
6
6
  has_many @join_name.to_sym, dependent: :delete_all
7
7
  has_many right_relation.to_s.pluralize.to_sym, through: @join_name.to_sym
8
8
  accepts_nested_attributes_for @join_name.to_sym, allow_destroy: true
9
- attr_accessible "#{@join_name}_attributes"
9
+
10
+ unless defined? ActionController::StrongParameters
11
+ attr_accessible "#{@join_name}_attributes"
12
+ end
10
13
 
11
14
  include AssignsHasManyThroughRelations::ModelInstanceMethods
12
15
  end
@@ -16,7 +19,7 @@ module AssignsHasManyThroughRelations
16
19
 
17
20
  module ModelInstanceMethods
18
21
  def get_join_model_for(relation)
19
- send(self.class.join_name).where("#{relation.class.name.underscore}_id" => relation.id).first
22
+ send(self.class.join_name).where("#{relation.class.base_class.name.underscore}_id" => relation.id).first
20
23
  end
21
24
  end
22
25
  end
@@ -1,3 +1,3 @@
1
1
  module AssignsHasManyThroughRelations
2
- VERSION = "0.0.11"
2
+ VERSION = "0.0.13"
3
3
  end
metadata CHANGED
@@ -1,27 +1,27 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: assigns_has_many_through_relations
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.11
4
+ version: 0.0.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Diego Salazar
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-16 00:00:00.000000000 Z
11
+ date: 2015-10-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
15
15
  requirement: !ruby/object:Gem::Requirement
16
16
  requirements:
17
- - - "~>"
17
+ - - ">="
18
18
  - !ruby/object:Gem::Version
19
19
  version: '3'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
- - - "~>"
24
+ - - ">="
25
25
  - !ruby/object:Gem::Version
26
26
  version: '3'
27
27
  - !ruby/object:Gem::Dependency
@@ -65,6 +65,7 @@ files:
65
65
  - README.md
66
66
  - Rakefile
67
67
  - app/assets/.DS_Store
68
+ - app/assets/javascripts/assigns_has_many_through_relations.js
68
69
  - app/assets/javascripts/assigns_has_many_through_relations/plugins.js
69
70
  - app/assets/stylesheets/.DS_Store
70
71
  - app/assets/stylesheets/assigns_has_many_through_relations/application.css.scss
@@ -98,7 +99,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
99
  version: '0'
99
100
  requirements: []
100
101
  rubyforge_project:
101
- rubygems_version: 2.4.3
102
+ rubygems_version: 2.4.6
102
103
  signing_key:
103
104
  specification_version: 4
104
105
  summary: Rails Engine that provides a management UI to assign models to each other