Skip to content

Commit

Permalink
updates for rails 4 compatability
Browse files Browse the repository at this point in the history
  • Loading branch information
twalpole committed Jan 24, 2013
1 parent c5e311a commit a22b424
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 5 deletions.
7 changes: 7 additions & 0 deletions lib/formtastic/form_builder.rb
Expand Up @@ -81,6 +81,13 @@ def semantic_fields_for(record_or_name_or_array, *args, &block)
fields_for(record_or_name_or_array, *(args << options), &block)
end

def initialize(object_name, object, template, options, block=nil)
super
if respond_to?('multipart=') && options.is_a?(Hash) && options[:html]
self.multipart = options[:html][:multipart]
end
end

end

end
Expand Down
7 changes: 5 additions & 2 deletions lib/formtastic/inputs/base/timeish.rb
Expand Up @@ -188,8 +188,11 @@ def position(fragment)

def i18n_date_fragments
order = ::I18n.t(:order, :scope => [:date])
order = nil unless order.is_a?(Array)
order
if order.is_a?(Array)
order.map &:to_sym
else
nil
end
end

def fragments_wrapping(&block)
Expand Down
4 changes: 3 additions & 1 deletion lib/formtastic/inputs/select_input.rb
Expand Up @@ -198,8 +198,10 @@ def input_html_options
def extra_input_html_options
{
:multiple => multiple?,
:name => multiple? ? input_html_options_name_multiple : input_html_options_name
:name => (multiple? && Rails::VERSION::MAJOR == 3) ? input_html_options_name_multiple : input_html_options_name
}


end

def input_html_options_name
Expand Down
2 changes: 1 addition & 1 deletion spec/helpers/form_helper_spec.rb
Expand Up @@ -152,7 +152,7 @@

it 'is restored to its original value after the form is rendered' do
lambda do
Formtastic::Helpers::FormHelper.field_error_proc = proc {}
Formtastic::Helpers::FormHelper.field_error_proc = proc {""}
semantic_form_for(@new_post, :url => '/hello') { |builder| }
end.should_not change(::ActionView::Base, :field_error_proc)
end
Expand Down
5 changes: 4 additions & 1 deletion spec/spec_helper.rb
Expand Up @@ -36,7 +36,10 @@ module FormtasticSpecHelper
include ActionView::Helpers::AssetTagHelper
include ActiveSupport
include ActionController::PolymorphicRoutes if defined?(ActionController::PolymorphicRoutes)

include ActionDispatch::Routing::PolymorphicRoutes
include AbstractController::UrlFor if defined?(AbstractController::UrlFor)
include ActionView::RecordIdentifier if defined?(ActionView::RecordIdentifier)

include Formtastic::Helpers::FormHelper

def default_input_type(column_type, column_name = :generic_column_name)
Expand Down
1 change: 1 addition & 0 deletions spec/support/test_environment.rb
Expand Up @@ -17,6 +17,7 @@ class Application < Rails::Application
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
config.active_support.deprecation = :stderr
config.secret_key_base = "secret"
end
end
FormtasticTest::Application.initialize!
Expand Down

0 comments on commit a22b424

Please sign in to comment.