formula 0.2.0 → 0.2.1

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.
Files changed (3) hide show
  1. data/lib/formula.rb +47 -5
  2. data/lib/formula/version.rb +1 -1
  3. metadata +4 -12
data/lib/formula.rb CHANGED
@@ -202,16 +202,37 @@ module Formula
202
202
  # Usage:
203
203
  #
204
204
  # f.association(:category_id, Category.all, :id, :name, :hint => "What do you do?")
205
+ # f.association(:category_id, Category.all, :id, :name, :association => { :prompt => "Category?" })
206
+ # f.association(:category_id, Category.all, :id, :name, :association => { :html => { :class => "category" } })
205
207
  #
206
208
  # Equivalent:
207
209
  #
208
210
  # <div>
209
211
  # <div class="association">
210
212
  # <%= f.label(:category_id)
211
- # <div class="association"><%= f.collection_select(:category_id, Category.all, :id, :name) %></div>
213
+ # <div class="association">
214
+ # <%= f.collection_select(:category_id, Category.all, :id, :name) %>
215
+ # </div>
212
216
  # <div class="hint">What do you do?</div>
213
217
  # </div>
214
218
  # </div>
219
+ # <div>
220
+ # <div class="association">
221
+ # <%= f.label(:category_id)
222
+ # <div class="association">
223
+ # <%= f.collection_select(:category_id, Category.all, :id, :name, { :prompt => "Category") } %>
224
+ # </div>
225
+ # </div>
226
+ # </div>
227
+ # <div>
228
+ # <div class="association">
229
+ # <%= f.label(:category_id)
230
+ # <div class="association">
231
+ # <%= f.collection_select(:category_id, Category.all, :id, :name, {}, { :class => "category" } %>
232
+ # </div>
233
+ # </div>
234
+ # </div>
235
+
215
236
 
216
237
  def association(method, collection, value, text, options = {})
217
238
  options[:as] ||= :select
@@ -220,7 +241,8 @@ module Formula
220
241
  self.block(method, options) do
221
242
  @template.content_tag(::Formula.association_tag, :class => [::Formula.association_class, options[:as]]) do
222
243
  case options[:as]
223
- when :select then collection_select(method, collection, value, text, options[:association])
244
+ when :select then collection_select(method, collection, value, text,
245
+ options[:association], options[:association].delete(:html))
224
246
  end
225
247
  end
226
248
  end
@@ -317,7 +339,25 @@ module Formula
317
339
 
318
340
 
319
341
  public
320
-
342
+
343
+
344
+ # Generates a wrapper around fields_form with :builder set to FormulaFormBuilder.
345
+ #
346
+ # Supports:
347
+ #
348
+ # * f.formula_fields_for(@user.company)
349
+ # * f.fieldsula_for(@user.company)
350
+ #
351
+ # Equivalent:
352
+ #
353
+ # * f.fields_for(@user.company, :builder => Formula::FormulaFormBuilder))
354
+ #
355
+ # Usage:
356
+ #
357
+ # <% f.formula_fields_for(@user.company) do |company_f| %>
358
+ # <%= company_f.input :url %>
359
+ # <%= company_f.input :phone %>
360
+ # <% end %>
321
361
 
322
362
  def formula_fields_for(record_or_name_or_array, *args, &block)
323
363
  options = args.extract_options!
@@ -325,6 +365,8 @@ module Formula
325
365
  fields_for(record_or_name_or_array, *(args << options), &block)
326
366
  end
327
367
 
368
+ alias :fieldsula_for :formula_fields_for
369
+
328
370
 
329
371
  end
330
372
 
@@ -358,7 +400,7 @@ module Formula
358
400
  alias :formula_for :formula_form_for
359
401
 
360
402
 
361
- # Generates a wrapper around fields_form with :builder set to FormulaFormBuilder.
403
+ # Generates a wrapper around fields_for with :builder set to FormulaFormBuilder.
362
404
  #
363
405
  # Supports:
364
406
  #
@@ -371,7 +413,7 @@ module Formula
371
413
  #
372
414
  # Usage:
373
415
  #
374
- # <% f.formula_form_for(@user.company) do |company_f| %>
416
+ # <% f.formula_fields_for(@user.company) do |company_f| %>
375
417
  # <%= company_f.input :url %>
376
418
  # <%= company_f.input :phone %>
377
419
  # <% end %>
@@ -1,3 +1,3 @@
1
1
  module Formula
2
- VERSION = "0.2.0"
2
+ VERSION = "0.2.1"
3
3
  end
metadata CHANGED
@@ -1,12 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: formula
3
3
  version: !ruby/object:Gem::Version
4
- prerelease: false
5
- segments:
6
- - 0
7
- - 2
8
- - 0
9
- version: 0.2.0
4
+ prerelease:
5
+ version: 0.2.1
10
6
  platform: ruby
11
7
  authors:
12
8
  - Kevin Sylvestre
@@ -14,7 +10,7 @@ autorequire:
14
10
  bindir: bin
15
11
  cert_chain: []
16
12
 
17
- date: 2011-01-25 00:00:00 -05:00
13
+ date: 2011-02-12 00:00:00 -05:00
18
14
  default_executable:
19
15
  dependencies: []
20
16
 
@@ -49,21 +45,17 @@ required_ruby_version: !ruby/object:Gem::Requirement
49
45
  requirements:
50
46
  - - ">="
51
47
  - !ruby/object:Gem::Version
52
- segments:
53
- - 0
54
48
  version: "0"
55
49
  required_rubygems_version: !ruby/object:Gem::Requirement
56
50
  none: false
57
51
  requirements:
58
52
  - - ">="
59
53
  - !ruby/object:Gem::Version
60
- segments:
61
- - 0
62
54
  version: "0"
63
55
  requirements: []
64
56
 
65
57
  rubyforge_project:
66
- rubygems_version: 1.3.7
58
+ rubygems_version: 1.5.0
67
59
  signing_key:
68
60
  specification_version: 3
69
61
  summary: A great way to simplify complex forms