wnm_support 0.0.4 → 0.0.5

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.
data/README.md CHANGED
@@ -6,7 +6,7 @@ add some useful methods to core class for rails project
6
6
 
7
7
  Add this line to your application's Gemfile:
8
8
 
9
- gem "wnm_support", :git => "git@bitbucket.org:mirrec/wnm_support.git"
9
+ gem "wnm_support"
10
10
 
11
11
  And then execute:
12
12
 
@@ -95,6 +95,14 @@ And then execute:
95
95
  video = youtube_video(url, 100, 200)
96
96
  video # => <object width='100' height='200'><param url='youtube.com/v/lala'>...</object>
97
97
 
98
+ # use inside form_group
99
+ <%= form_group t("sample.title") do %>
100
+ <%= f.fields_for :some_attributes do |builder| %>
101
+ <%= render :partial => 'some_partial_with_inputs_to_add', :locals => {:f => builder} %>
102
+ <% end %>
103
+ <%= link_to_add_fields t("sample.add_title"), f, :some_attributes %>
104
+ <% end %>
105
+
98
106
  ## Contributing
99
107
 
100
108
  1. Fork it
data/changelog.md CHANGED
@@ -1,3 +1,8 @@
1
+ # 0.0.5
2
+ ## added
3
+ * view helper LinkToAddFields
4
+ * readme section for view helper LinkToAddFields
5
+
1
6
  # 0.0.4
2
7
  ## added
3
8
  * view helper BoolToHuman
data/lib/wnm_support.rb CHANGED
@@ -20,5 +20,6 @@ require "wnm_support/active_record_ext/mysql_order_by_field"
20
20
 
21
21
  require "wnm_support/view_helpers/bool_to_human"
22
22
  require "wnm_support/view_helpers/youtube"
23
+ require "wnm_support/view_helpers/link_to_add_fields"
23
24
 
24
25
  require "wnm_support/railtie" if defined?(Rails)
@@ -4,6 +4,7 @@ module WnmSupport
4
4
  initializer "wnm_support.view_helpers" do
5
5
  ActionView::Base.send :include, BoolToHuman
6
6
  ActionView::Base.send :include, Youtube
7
+ ActionView::Base.send :include, LinkToAddFields
7
8
  end
8
9
 
9
10
  initializer "wnm_support.active_record_ext" do
@@ -1,3 +1,3 @@
1
1
  module WnmSupport
2
- VERSION = "0.0.4"
2
+ VERSION = "0.0.5"
3
3
  end
@@ -0,0 +1,14 @@
1
+ module WnmSupport
2
+ module ViewHelpers
3
+ module LinkToAddFields
4
+ def link_to_add_fields(name, f, association)
5
+ new_object = f.object.send(association).klass.new
6
+ id = new_object.object_id
7
+ fields = f.fields_for(association, new_object, {:child_index => id}) do |builder|
8
+ render(association.to_s.singularize + "_fields", {:f => builder})
9
+ end
10
+ link_to(name, '#', :class => "add_fields", :data => {:id => id, :fields => fields.gsub("\n", "")})
11
+ end
12
+ end
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wnm_support
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.4
4
+ version: 0.0.5
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-10-11 00:00:00.000000000 Z
12
+ date: 2012-10-18 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport
@@ -156,6 +156,7 @@ files:
156
156
  - lib/wnm_support/railtie.rb
157
157
  - lib/wnm_support/version.rb
158
158
  - lib/wnm_support/view_helpers/bool_to_human.rb
159
+ - lib/wnm_support/view_helpers/link_to_add_fields.rb
159
160
  - lib/wnm_support/view_helpers/youtube.rb
160
161
  - spec/spec_helper.rb
161
162
  - spec/wnm_support/activer_record_ext/destroy_validation_spec.rb
@@ -171,6 +172,7 @@ files:
171
172
  - spec/wnm_support/core_ext/string_spec.rb
172
173
  - spec/wnm_support/core_ext/true_class_spec.rb
173
174
  - spec/wnm_support/view_helpers/bool_to_human_spec.rb
175
+ - spec/wnm_support/view_helpers/link_to_add_fields_spec.rb
174
176
  - spec/wnm_support/view_helpers/youtube_spec.rb
175
177
  - wnm_support.gemspec
176
178
  homepage: https://github.com/mirrec/wnm_support
@@ -212,4 +214,5 @@ test_files:
212
214
  - spec/wnm_support/core_ext/string_spec.rb
213
215
  - spec/wnm_support/core_ext/true_class_spec.rb
214
216
  - spec/wnm_support/view_helpers/bool_to_human_spec.rb
217
+ - spec/wnm_support/view_helpers/link_to_add_fields_spec.rb
215
218
  - spec/wnm_support/view_helpers/youtube_spec.rb