diff --git a/vendor/plugins/blitz/features/step_definitions/view_steps.rb b/vendor/plugins/blitz/features/step_definitions/view_steps.rb index a99ffb8..3c27fde 100644 --- a/vendor/plugins/blitz/features/step_definitions/view_steps.rb +++ b/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 "
\n" << " <%= form.string :title %>\n" << " <%= form.text :body %>\n" << - " <%= form.collection :user %>\n" << + " <%= form.belongs_to :user %>\n" << "
\n" << "
\n" << " <%= form.submit 'Create', :disable_with => 'Please wait...' %>\n" << diff --git a/vendor/plugins/blitz/generators/support/generator_helper.rb b/vendor/plugins/blitz/generators/support/generator_helper.rb index af472e3..f337b96 100644 --- a/vendor/plugins/blitz/generators/support/generator_helper.rb +++ b/vendor/plugins/blitz/generators/support/generator_helper.rb @@ -36,7 +36,7 @@ module Blitz def name_and_type(column) if belongs_to_column?(column.name) - [column.name.gsub("_id", ""), :collection] + [column.name.gsub("_id", ""), :belongs_to] else [column.name, column.type] end diff --git a/vendor/plugins/semi_formal/lib/semi_formal.rb b/vendor/plugins/semi_formal/lib/semi_formal.rb index e03ca13..431b8af 100644 --- a/vendor/plugins/semi_formal/lib/semi_formal.rb +++ b/vendor/plugins/semi_formal/lib/semi_formal.rb @@ -42,25 +42,27 @@ class SemiFormal < ActionView::Helpers::FormBuilder "
" end - def collection(field, *args) + def belongs_to(field, *args) options = args.extract_options! reflection = @object.class.reflect_on_association(field) - collection = reflection.class.all.collect {|each| [each.name, each.id] } + collection = reflection.klass.all.collect {|each| [each.to_s, each.id] } - html_options = {} - options[:include_blank] = true + options[:select] ||= {} + options[:select][:include_blank] = true - if [:has_many, :has_and_belongs_to_many].include?(reflection.macro) - html_options[:multiple] ||= true - html_options[:size] ||= 5 - end - - "
" + + "
" + label(field, options[:label] || {}) + - select(field, collection, options, html_options) + select(field, collection, options[:select] || {}) "
" end + + # has_many? + # if [:has_many, :has_and_belongs_to_many].include?(reflection.macro) + # html_options[:multiple] ||= true + # html_options[:size] ||= 5 + # end + end ActionView::Base.default_form_builder = SemiFormal -- libgit2 0.21.2