Commit d89eda9273d95caa17aba76db36a9f447dc778c3
1 parent
9f845b63
Exists in
master
and in
1 other branch
updated blitz, semi formal
Showing
3 changed files
with
15 additions
and
13 deletions
Show diff stats
vendor/plugins/blitz/features/step_definitions/view_steps.rb
... | ... | @@ -32,7 +32,7 @@ Then /^a SemiFormal "new" view for "posts" should be generated with fields$/ do |
32 | 32 | " <fieldset class=\"inputs\">\n" << |
33 | 33 | " <%= form.string :title %>\n" << |
34 | 34 | " <%= form.text :body %>\n" << |
35 | - " <%= form.collection :user %>\n" << | |
35 | + " <%= form.belongs_to :user %>\n" << | |
36 | 36 | " </fieldset>\n" << |
37 | 37 | " <fieldset class=\"buttons\">\n" << |
38 | 38 | " <%= form.submit 'Create', :disable_with => 'Please wait...' %>\n" << | ... | ... |
vendor/plugins/blitz/generators/support/generator_helper.rb
vendor/plugins/semi_formal/lib/semi_formal.rb
... | ... | @@ -42,25 +42,27 @@ class SemiFormal < ActionView::Helpers::FormBuilder |
42 | 42 | "<div>" |
43 | 43 | end |
44 | 44 | |
45 | - def collection(field, *args) | |
45 | + def belongs_to(field, *args) | |
46 | 46 | options = args.extract_options! |
47 | 47 | |
48 | 48 | reflection = @object.class.reflect_on_association(field) |
49 | - collection = reflection.class.all.collect {|each| [each.name, each.id] } | |
49 | + collection = reflection.klass.all.collect {|each| [each.to_s, each.id] } | |
50 | 50 | |
51 | - html_options = {} | |
52 | - options[:include_blank] = true | |
51 | + options[:select] ||= {} | |
52 | + options[:select][:include_blank] = true | |
53 | 53 | |
54 | - if [:has_many, :has_and_belongs_to_many].include?(reflection.macro) | |
55 | - html_options[:multiple] ||= true | |
56 | - html_options[:size] ||= 5 | |
57 | - end | |
58 | - | |
59 | - "<div class=\"collection\">" + | |
54 | + "<div class=\"belongs_to\">" + | |
60 | 55 | label(field, options[:label] || {}) + |
61 | - select(field, collection, options, html_options) | |
56 | + select(field, collection, options[:select] || {}) | |
62 | 57 | "<div>" |
63 | 58 | end |
59 | + | |
60 | + # has_many? | |
61 | + # if [:has_many, :has_and_belongs_to_many].include?(reflection.macro) | |
62 | + # html_options[:multiple] ||= true | |
63 | + # html_options[:size] ||= 5 | |
64 | + # end | |
65 | + | |
64 | 66 | end |
65 | 67 | |
66 | 68 | ActionView::Base.default_form_builder = SemiFormal | ... | ... |