From 071196e97bcf71169f8afc21c8ea9181110f44e0 Mon Sep 17 00:00:00 2001 From: Jacques Crocker Date: Thu, 29 Jul 2010 16:21:48 -0700 Subject: [PATCH] Upgrading to Rails3 rc --- Gemfile | 6 +- Gemfile.lock | 118 ++++++++++++++-------------- app/models/membership.rb | 2 +- config/environments/development.rb | 2 + config/environments/production.rb | 15 ++++ config/environments/test.rb | 6 ++ config/initializers/formtastic.rb | 4 +- lib/locomotive.rb | 3 + lib/locomotive/heroku.rb | 1 + lib/locomotive/misc_form_builder.rb | 47 +++++++++++ lib/locomotive/routing.rb | 2 + lib/misc_form_builder.rb | 45 ----------- 12 files changed, 139 insertions(+), 112 deletions(-) create mode 100644 lib/locomotive/misc_form_builder.rb create mode 100644 lib/locomotive/routing.rb delete mode 100644 lib/misc_form_builder.rb diff --git a/Gemfile b/Gemfile index 321870a6..baf98f57 100644 --- a/Gemfile +++ b/Gemfile @@ -1,7 +1,7 @@ # Edit this Gemfile to bundle your application's dependencies. -source 'http://gemcutter.org' +source 'http://rubygems.org' -gem 'rails', '3.0.0.beta4' +gem 'rails', '3.0.0.rc' gem 'liquid', '2.0.0' gem 'bson_ext', '>= 1.0.1' @@ -29,7 +29,7 @@ group :development do gem 'mongrel' gem 'cgi_multipart_eof_fix' gem 'fastthread' - gem 'mongrel_experimental' + # gem 'mongrel_experimental' end group :test, :development do diff --git a/Gemfile.lock b/Gemfile.lock index ee9083a5..93ea47d0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -7,7 +7,7 @@ GIT GIT remote: http://github.com/justinfrench/formtastic.git - revision: e7e29b6 + revision: 4481341 branch: rails3 specs: formtastic (1.0.0.beta2) @@ -16,42 +16,41 @@ GIT i18n (>= 0.4.0) GEM - remote: http://gemcutter.org/ - remote: http://gems.github.com/ + remote: http://rubygems.org/ specs: RedCloth (4.2.3) abstract (1.0.0) - actionmailer (3.0.0.beta4) - actionpack (= 3.0.0.beta4) - mail (~> 2.2.3) + actionmailer (3.0.0.rc) + actionpack (= 3.0.0.rc) + mail (~> 2.2.5) actionmailer-with-request (0.1.1) - actionpack (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) + actionpack (3.0.0.rc) + activemodel (= 3.0.0.rc) + activesupport (= 3.0.0.rc) builder (~> 2.1.2) - erubis (~> 2.6.5) + erubis (~> 2.6.6) i18n (~> 0.4.1) - rack (~> 1.1.0) - rack-mount (~> 0.6.3) + rack (~> 1.2.1) + rack-mount (~> 0.6.9) rack-test (~> 0.5.4) - tzinfo (~> 0.3.16) - activemodel (3.0.0.beta4) - activesupport (= 3.0.0.beta4) + tzinfo (~> 0.3.22) + activemodel (3.0.0.rc) + activesupport (= 3.0.0.rc) builder (~> 2.1.2) i18n (~> 0.4.1) - activerecord (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) + activerecord (3.0.0.rc) + activemodel (= 3.0.0.rc) + activesupport (= 3.0.0.rc) arel (~> 0.4.0) - tzinfo (~> 0.3.16) - activeresource (3.0.0.beta4) - activemodel (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - activesupport (3.0.0.beta4) + tzinfo (~> 0.3.22) + activeresource (3.0.0.rc) + activemodel (= 3.0.0.rc) + activesupport (= 3.0.0.rc) + activesupport (3.0.0.rc) arel (0.4.0) activesupport (>= 3.0.0.beta) autotest (4.3.2) - aws (2.3.13) + aws (2.3.20) http_connection uuidtools xml-simple @@ -108,7 +107,7 @@ GEM git (1.2.5) haml (3.0.13) has_scope (0.5.0) - heroku (1.9.11) + heroku (1.9.13) json_pure (>= 1.2.0, < 1.5.0) launchy (~> 0.3.2) rest-client (~> 1.4.0) @@ -137,59 +136,57 @@ GEM treetop (>= 1.4.5) mime-types (1.16) mimetype-fu (0.1.2) - mongo (1.0.5) + mongo (1.0.6) bson (>= 1.0.4) mongo_session_store (2.0.0.pre) actionpack (~> 3.0) - mongoid (2.0.0.beta11) - activemodel (~> 3.0.0.beta) - bson (~> 1.0.4) - mongo (~> 1.0.5) - tzinfo (~> 0.3.22) + mongoid (2.0.0.beta.15) + activemodel (= 3.0.0.rc) + bson (= 1.0.4) + mongo (= 1.0.6) + tzinfo (= 0.3.22) will_paginate (~> 3.0.pre) mongoid_acts_as_tree (0.1.5) bson (>= 0.20.1) mongoid (<= 2.0.0) - mongrel (1.1) + mongrel (1.1.5) cgi_multipart_eof_fix (>= 2.4) daemons (>= 1.0.3) fastthread (>= 1.0.1) gem_plugin (>= 0.2.3) - mongrel_experimental (1.1) - mongrel (= 1.1) - nokogiri (1.4.2) + nokogiri (1.4.3.1) polyglot (0.3.1) - rack (1.1.0) + rack (1.2.1) rack-mount (0.6.9) rack (>= 1.0.0) rack-test (0.5.4) rack (>= 1.0) - rails (3.0.0.beta4) - actionmailer (= 3.0.0.beta4) - actionpack (= 3.0.0.beta4) - activerecord (= 3.0.0.beta4) - activeresource (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) - bundler (>= 0.9.26) - railties (= 3.0.0.beta4) - railties (3.0.0.beta4) - actionpack (= 3.0.0.beta4) - activesupport (= 3.0.0.beta4) + rails (3.0.0.rc) + actionmailer (= 3.0.0.rc) + actionpack (= 3.0.0.rc) + activerecord (= 3.0.0.rc) + activeresource (= 3.0.0.rc) + activesupport (= 3.0.0.rc) + bundler (>= 1.0.0.rc.1) + railties (= 3.0.0.rc) + railties (3.0.0.rc) + actionpack (= 3.0.0.rc) + activesupport (= 3.0.0.rc) rake (>= 0.8.3) - thor (~> 0.13.6) + thor (~> 0.14.0) rake (0.8.7) - responders (0.6.1) + responders (0.6.2) rest-client (1.4.2) mime-types (>= 1.16) rmagick (2.12.2) - rspec (2.0.0.beta.18) - rspec-core (= 2.0.0.beta.18) - rspec-expectations (= 2.0.0.beta.18) - rspec-mocks (= 2.0.0.beta.18) - rspec-core (2.0.0.beta.18) - rspec-expectations (2.0.0.beta.18) + rspec (2.0.0.beta.19) + rspec-core (= 2.0.0.beta.19) + rspec-expectations (= 2.0.0.beta.19) + rspec-mocks (= 2.0.0.beta.19) + rspec-core (2.0.0.beta.19) + rspec-expectations (2.0.0.beta.19) diff-lcs (>= 1.1.2) - rspec-mocks (2.0.0.beta.18) + rspec-mocks (2.0.0.beta.19) rspec-rails (2.0.0.beta.18) rspec (>= 2.0.0.beta.14) webrat (>= 0.7.0) @@ -201,14 +198,14 @@ GEM rubyforge (2.0.4) json_pure (>= 1.1.7) rubyzip (0.9.4) - selenium-webdriver (0.0.26) + selenium-webdriver (0.0.27) ffi (>= 0.6.1) json_pure rubyzip spork (0.8.4) stackdeck (0.2.0) term-ansicolor (1.0.5) - thor (0.13.8) + thor (0.14.0) treetop (1.4.8) polyglot (>= 0.3.1) trollop (1.16.2) @@ -220,7 +217,7 @@ GEM nokogiri (>= 1.2.0) rack (>= 1.0) rack-test (>= 0.5.3) - will_paginate (3.0.pre) + will_paginate (3.0.pre2) xml-simple (1.0.12) PLATFORMS @@ -256,8 +253,7 @@ DEPENDENCIES mongoid (= 2.0.0.beta.15) mongoid_acts_as_tree (= 0.1.5) mongrel - mongrel_experimental - rails (= 3.0.0.beta4) + rails (= 3.0.0.rc) rmagick (= 2.12.2) rspec-rails (= 2.0.0.beta.18) ruby-debug diff --git a/app/models/membership.rb b/app/models/membership.rb index 706c1409..0a710ff2 100644 --- a/app/models/membership.rb +++ b/app/models/membership.rb @@ -25,7 +25,7 @@ class Membership if @email.blank? self.errors.add_on_blank(:email) :error - elsif self.account.nil? + elsif self.account.blank? :create_account elsif self.site.memberships.find_all { |m| m.account_id == self.account_id }.size > 1 self.errors.add(:base, 'Already created') diff --git a/config/environments/development.rb b/config/environments/development.rb index 7d20df73..a0d99d89 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -17,6 +17,8 @@ Locomotive::Application.configure do # Don't care if the mailer can't send config.action_mailer.raise_delivery_errors = false + config.active_support.deprecation = :log + # config.action_mailer.default_url_options = { :host => 'localhost:3000' } # MockSmtp settings diff --git a/config/environments/production.rb b/config/environments/production.rb index 1d300072..b9d301b5 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -9,6 +9,15 @@ Locomotive::Application.configure do config.consider_all_requests_local = false config.action_controller.perform_caching = true + # Specifies the header that your server uses for sending files + config.action_dispatch.x_sendfile_header = "X-Sendfile" + + # For nginx: + # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' + + # If you have no front-end server that supports something like X-Sendfile, + # just comment this out and Rails will serve the files + # See everything in the log (default is :info) # config.log_level = :debug @@ -30,4 +39,10 @@ Locomotive::Application.configure do # Enable threaded mode # config.threadsafe! + + # Enable locale fallbacks for I18n (makes lookups for any locale fall back to + # the I18n.default_locale when a translation can not be found) + config.i18n.fallbacks = true + + config.active_support.deprecation = :notify end diff --git a/config/environments/test.rb b/config/environments/test.rb index ac3458bd..fad93e95 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -14,6 +14,9 @@ Locomotive::Application.configure do config.consider_all_requests_local = true config.action_controller.perform_caching = false + # Raise exceptions instead of rendering exception templates + config.action_dispatch.show_exceptions = false + # Disable request forgery protection in test environment config.action_controller.allow_forgery_protection = false @@ -26,6 +29,9 @@ Locomotive::Application.configure do # This is necessary if your schema can't be completely dumped by the schema dumper, # like if you have constraints or database-specific column types # config.active_record.schema_format = :sql + + # Print deprecation notices to the stderr + config.active_support.deprecation = :stderr end CarrierWave.configure do |config| diff --git a/config/initializers/formtastic.rb b/config/initializers/formtastic.rb index 6cad3b7f..985d11ae 100644 --- a/config/initializers/formtastic.rb +++ b/config/initializers/formtastic.rb @@ -1,5 +1,5 @@ require 'formtastic' - -Formtastic::SemanticFormHelper.builder = MiscFormBuilder +require 'locomotive/misc_form_builder' +Formtastic::SemanticFormHelper.builder = Locomotive::MiscFormBuilder Formtastic::SemanticFormBuilder.i18n_lookups_by_default = true diff --git a/lib/locomotive.rb b/lib/locomotive.rb index 254703a4..8ecf4657 100644 --- a/lib/locomotive.rb +++ b/lib/locomotive.rb @@ -9,6 +9,9 @@ require 'locomotive/custom_fields' require 'locomotive/httparty' require 'locomotive/inherited_resources' require 'locomotive/admin_responder' +require 'locomotive/routing' +require 'locomotive/regexps' +require 'locomotive/render' require 'mongo_session_store/mongoid' diff --git a/lib/locomotive/heroku.rb b/lib/locomotive/heroku.rb index 8795aa52..d0a809cb 100644 --- a/lib/locomotive/heroku.rb +++ b/lib/locomotive/heroku.rb @@ -1,4 +1,5 @@ require 'heroku' +require 'locomotive/heroku/custom_domain' module Locomotive module Heroku diff --git a/lib/locomotive/misc_form_builder.rb b/lib/locomotive/misc_form_builder.rb new file mode 100644 index 00000000..3675c652 --- /dev/null +++ b/lib/locomotive/misc_form_builder.rb @@ -0,0 +1,47 @@ +module Locomotive + class MiscFormBuilder < Formtastic::SemanticFormBuilder + + @@all_fields_required_by_default = false + + def foldable_inputs(*args, &block) + opts = args.extract_options! + + unfolded = !(opts[:class] || '').index('off').nil? || @object.new_record? || !@object.errors.empty? + + opts[:class] = (opts[:class] || '') + " inputs foldable #{'folded' unless unfolded}" + args.push(opts) + self.inputs(*args, &block) + end + + def custom_input(name, options = {}, &block) + default_options = { :css => '', :with_label => true, :label => nil } + options = default_options.merge(options) + + html = options[:with_label] ? self.label(options[:label] || name) : '' + html += template.capture(&block) || '' + html += inline_hints_for(name, options) || '' + html += self.errors_on(name) || '' + + template.content_tag(:li, template.find_and_preserve(html), :class => "#{options[:css]} #{'error' unless @object.errors[name].empty?}") + end + + def inline_errors_on(method, options = nil) + if render_inline_errors? + errors = @object.errors[method.to_sym] + template.content_tag(:span, [*errors].to_sentence.untaint, :class => 'inline-errors') if errors.present? + else + nil + end + end + + def normalize_model_name(name) + if name =~ /(.+)\/(.+)/ + [$1, $2] + else + super + end + end + + + end +end \ No newline at end of file diff --git a/lib/locomotive/routing.rb b/lib/locomotive/routing.rb new file mode 100644 index 00000000..ba0a44ae --- /dev/null +++ b/lib/locomotive/routing.rb @@ -0,0 +1,2 @@ +require 'locomotive/routing/default_constraint' +require 'locomotive/routing/site_dispatcher' diff --git a/lib/misc_form_builder.rb b/lib/misc_form_builder.rb deleted file mode 100644 index 4a098abd..00000000 --- a/lib/misc_form_builder.rb +++ /dev/null @@ -1,45 +0,0 @@ -class MiscFormBuilder < Formtastic::SemanticFormBuilder - - @@all_fields_required_by_default = false - - def foldable_inputs(*args, &block) - opts = args.extract_options! - - unfolded = !(opts[:class] || '').index('off').nil? || @object.new_record? || !@object.errors.empty? - - opts[:class] = (opts[:class] || '') + " inputs foldable #{'folded' unless unfolded}" - args.push(opts) - self.inputs(*args, &block) - end - - def custom_input(name, options = {}, &block) - default_options = { :css => '', :with_label => true, :label => nil } - options = default_options.merge(options) - - html = options[:with_label] ? self.label(options[:label] || name) : '' - html += template.capture(&block) || '' - html += inline_hints_for(name, options) || '' - html += self.errors_on(name) || '' - - template.content_tag(:li, template.find_and_preserve(html), :class => "#{options[:css]} #{'error' unless @object.errors[name].empty?}") - end - - def inline_errors_on(method, options = nil) - if render_inline_errors? - errors = @object.errors[method.to_sym] - template.content_tag(:span, [*errors].to_sentence.untaint, :class => 'inline-errors') if errors.present? - else - nil - end - end - - def normalize_model_name(name) - if name =~ /(.+)\/(.+)/ - [$1, $2] - else - super - end - end - - -end