awesome_nested_fields 0.1.0 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,19 +7,34 @@ In Rails, you can create forms that have fields from nested models. For example,
7
7
  Installation
8
8
  ------------
9
9
 
10
- 1. Add the gem to your Gemfile.
10
+ ### Rails 3.1
11
+
12
+ 1. Add the gem to your Gemfile and run `bundle install` to make sure the gem gets installed.
11
13
 
12
14
  gem 'awesome_nested_fields'
13
15
 
14
- 2. Run bundler to make sure the gem gets installed.
16
+ 2. Add this line to `app/assets/javascripts/application.js` (or where you prefer) so the javascript dependency is added to the asset pipeline. Be sure to include this line after jQuery and jQuery UJS Adapter.
17
+
18
+ //= require jquery.nested-fields
19
+
20
+ 3. Rock with your _awesome_ nested models.
21
+
22
+
23
+ ### Rails 3.0
24
+
25
+ 1. Add the gem to your Gemfile and run `bundle install` to make sure the gem gets installed. Be sure to include it after `jquery-rails` so the javascript files are added in the correct order at the templates.
26
+
27
+ gem 'awesome_nested_fields'
28
+
29
+ 2. Copy the javascript dependency to `public\javascripts` by using the generator.
30
+
31
+ rails generate awesome_nested_fields:install
32
+
33
+ 3. (Optional) The javascript dependency will be added automatically to the defaults javascript files. If you don't use `javascript_include_tag :defaults` in your templates for some reason, require the file manually.
15
34
 
16
- bundle install
17
-
18
- 3. Include the `jquery.nested-fields.js` file in your template (or in the pages that will use nested fields).
19
-
20
35
  <script src="/javascripts/jquery.nested-fields.js" type="text/javascript"></script>
21
36
 
22
- Now you're ready to rock with nested models. Don't forget to include the javascript file _after_ you've included jQuery. And don't worry because this file isn't on the public folder: it comes bundled into the gem.
37
+ 4. Now you're ready to rock with your _awesome_ nested models. It will be so fun as in Rails 3.1, I promise.
23
38
 
24
39
 
25
40
  Basic Usage
@@ -84,7 +99,7 @@ Now enjoy your new nested model form!
84
99
  Compatibility
85
100
  -------------
86
101
 
87
- awesome_nested_fields works only with Rails 3 and was tested with jQuery 1.5.0.
102
+ awesome_nested_fields works only with Rails 3.0 and Rails 3.1. Sorry, Rails 2.x users.
88
103
 
89
104
 
90
105
  TODO
@@ -94,7 +109,7 @@ TODO
94
109
  * Write awesome demos
95
110
  * Make sure it can degrade gracefully
96
111
  * Return and API object on JS to make interaction easier
97
- * Port JavaScript code to CoffeeScript
112
+ * Make `nested_fields` call compatible with Rails `fields_for`
98
113
 
99
114
 
100
115
  Copyleft
@@ -1,11 +1,9 @@
1
1
  module AwesomeNestedFields
2
- class Engine < Rails::Engine
3
- initializer 'awesome_nested_fields.add_middleware' do |app|
4
- app.middleware.use ActionDispatch::Static, "#{root}/public"
5
- end
6
-
7
- config.to_prepare do
8
- ApplicationController.helper(AwesomeNestedFieldsHelper)
9
- end
2
+ if ::Rails.version < '3.1'
3
+ require 'awesome_nested_fields/railtie'
4
+ else
5
+ require 'awesome_nested_fields/engine'
10
6
  end
7
+
8
+ require 'awesome_nested_fields/version'
11
9
  end
@@ -0,0 +1,5 @@
1
+ module AwesomeNestedFields
2
+ class Engine < ::Rails::Engine
3
+
4
+ end
5
+ end
@@ -0,0 +1,7 @@
1
+ module AwesomeNestedFields
2
+ class Railtie < ::Rails::Railtie
3
+ config.before_configuration do
4
+ config.action_view.javascript_expansions[:defaults] << 'jquery.nested-fields'
5
+ end
6
+ end
7
+ end
@@ -1,3 +1,3 @@
1
1
  module AwesomeNestedFields
2
- VERSION = "0.1.0"
2
+ VERSION = "0.2.0"
3
3
  end
@@ -0,0 +1,15 @@
1
+ require 'rails'
2
+
3
+ module AwesomeNestedFields
4
+ module Generators
5
+ class InstallGenerator < ::Rails::Generators::Base
6
+ desc 'This generator installs Awesome Nested Fields'
7
+ source_root File.expand_path('../../../../../vendor/assets/javascripts', __FILE__)
8
+
9
+ def copy_js
10
+ say_status('copying', 'awesome nested fields js file', :green)
11
+ copy_file 'jquery.nested-fields.js', 'public/javascripts/jquery.nested-fields.js'
12
+ end
13
+ end
14
+ end
15
+ end if ::Rails.version < '3.1'
@@ -1,5 +1,13 @@
1
1
  (function($) {
2
-
2
+ /**
3
+ *
4
+ * Awesome Nested Fields
5
+ *
6
+ * Requires jquery-ujs adapter.
7
+ * https://github.com/lailsonbm/awesome_nested_fields
8
+ *
9
+ */
10
+
3
11
  var defaultSettings = {
4
12
  beforeInsert: function(item, callback) { callback() },
5
13
  afterInsert: function(item) {},
metadata CHANGED
@@ -1,49 +1,44 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: awesome_nested_fields
3
- version: !ruby/object:Gem::Version
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
4
5
  prerelease:
5
- version: 0.1.0
6
6
  platform: ruby
7
- authors:
7
+ authors:
8
8
  - Lailson Bandeira
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
-
13
- date: 2011-06-06 00:00:00 -03:00
14
- default_executable:
15
- dependencies:
16
- - !ruby/object:Gem::Dependency
12
+ date: 2011-07-03 00:00:00.000000000Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
17
15
  name: bundler
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &2156703520 !ruby/object:Gem::Requirement
20
17
  none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
24
21
  version: 1.0.0
25
22
  type: :development
26
- version_requirements: *id001
27
- - !ruby/object:Gem::Dependency
28
- name: rails
29
23
  prerelease: false
30
- requirement: &id002 !ruby/object:Gem::Requirement
24
+ version_requirements: *2156703520
25
+ - !ruby/object:Gem::Dependency
26
+ name: rails
27
+ requirement: &2156703060 !ruby/object:Gem::Requirement
31
28
  none: false
32
- requirements:
33
- - - ">="
34
- - !ruby/object:Gem::Version
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
35
32
  version: 3.0.0
36
33
  type: :runtime
37
- version_requirements: *id002
34
+ prerelease: false
35
+ version_requirements: *2156703060
38
36
  description: Awesome dynamic nested fields for Rails and jQuery
39
37
  email: lailson@guava.com.br
40
38
  executables: []
41
-
42
39
  extensions: []
43
-
44
40
  extra_rdoc_files: []
45
-
46
- files:
41
+ files:
47
42
  - .gitignore
48
43
  - Gemfile
49
44
  - Gemfile.lock
@@ -53,35 +48,33 @@ files:
53
48
  - app/helpers/awesome_nested_fields_helper.rb
54
49
  - awesome_nested_fields.gemspec
55
50
  - lib/awesome_nested_fields.rb
51
+ - lib/awesome_nested_fields/engine.rb
52
+ - lib/awesome_nested_fields/railtie.rb
56
53
  - lib/awesome_nested_fields/version.rb
57
- - public/javascripts/jquery.nested-fields.js
58
- has_rdoc: true
54
+ - lib/generators/awesome_nested_fields/install/install_generator.rb
55
+ - vendor/assets/javascripts/jquery.nested-fields.js
59
56
  homepage: http://rubygems.org/gems/awesome_nested_fields
60
57
  licenses: []
61
-
62
58
  post_install_message:
63
59
  rdoc_options: []
64
-
65
- require_paths:
60
+ require_paths:
66
61
  - lib
67
- required_ruby_version: !ruby/object:Gem::Requirement
62
+ required_ruby_version: !ruby/object:Gem::Requirement
68
63
  none: false
69
- requirements:
70
- - - ">="
71
- - !ruby/object:Gem::Version
72
- version: "0"
73
- required_rubygems_version: !ruby/object:Gem::Requirement
64
+ requirements:
65
+ - - ! '>='
66
+ - !ruby/object:Gem::Version
67
+ version: '0'
68
+ required_rubygems_version: !ruby/object:Gem::Requirement
74
69
  none: false
75
- requirements:
76
- - - ">="
77
- - !ruby/object:Gem::Version
70
+ requirements:
71
+ - - ! '>='
72
+ - !ruby/object:Gem::Version
78
73
  version: 1.3.6
79
74
  requirements: []
80
-
81
75
  rubyforge_project: awesome_nested_fields
82
- rubygems_version: 1.6.2
76
+ rubygems_version: 1.8.5
83
77
  signing_key:
84
78
  specification_version: 3
85
79
  summary: Awesome nested fields for Rails
86
80
  test_files: []
87
-