From 47088f9b0e450c8423cf5cd6b4974977f5b1c0f7 Mon Sep 17 00:00:00 2001 From: did Date: Tue, 19 Jul 2011 14:52:02 +0200 Subject: [PATCH] fix issue #115 + clean code + exporting a site works now with ruby 1.8.7 --- app/controllers/admin/memberships_controller.rb | 13 ++++++------- lib/locomotive/export.rb | 6 +++++- lib/locomotive/import/assets.rb | 2 -- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/app/controllers/admin/memberships_controller.rb b/app/controllers/admin/memberships_controller.rb index 702207bc..d977884f 100644 --- a/app/controllers/admin/memberships_controller.rb +++ b/app/controllers/admin/memberships_controller.rb @@ -4,18 +4,17 @@ module Admin sections 'settings' def create - @membership = current_site.memberships.build(params[:membership]) - @membership.role = 'author' # force author by default + resource.role = 'author' # force author by default - case @membership.process! + case resource.process! when :create_account - redirect_to new_admin_account_url(:email => @membership.email) + redirect_to new_admin_account_url(:email => resource.email) when :save_it - respond_with @membership, :location => edit_admin_current_site_url + respond_with resource, :location => edit_admin_current_site_url when :error - respond_with @membership, :flash => true + respond_with resource, :flash => true when :already_created - respond_with @membership, :alert => t('flash.admin.memberships.create.already_created'), :location => edit_admin_current_site_url + respond_with resource, :alert => t('flash.admin.memberships.create.already_created'), :location => edit_admin_current_site_url end end diff --git a/lib/locomotive/export.rb b/lib/locomotive/export.rb index 3f2aca88..7bfd9abd 100644 --- a/lib/locomotive/export.rb +++ b/lib/locomotive/export.rb @@ -211,7 +211,11 @@ module Locomotive end def extract_attributes(object, fields) - object.attributes.select { |k, v| fields.include?(k) }.delete_if { |k, v| v.blank? } + if RUBY_VERSION =~ /1\.9/ + object.attributes.select { |k, v| fields.include?(k) } + else + object.attributes.reject { |k, v| !fields.include?(k) } + end.delete_if { |k, v| v.blank? } end def pages_folder diff --git a/lib/locomotive/import/assets.rb b/lib/locomotive/import/assets.rb index bde0709c..186782c2 100644 --- a/lib/locomotive/import/assets.rb +++ b/lib/locomotive/import/assets.rb @@ -29,8 +29,6 @@ module Locomotive rescue Exception => e self.log "!ERROR! = #{e.message}, #{asset_path}" end - - # site.reload end end end