From: Mohammed Morsi mmorsi@redhat.com
This largely gets rid of rails deprecations
(edited by Jason Guiditta jguiditt@redhat.com) (edited by Scott Seago sseago@redhat.com) --- src/app/controllers/application_controller.rb | 6 ++---- src/app/models/hardware_profile.rb | 2 +- src/app/models/provider.rb | 5 ++--- src/app/models/quota.rb | 2 ++ src/app/models/search_filter.rb | 2 +- src/app/models/task.rb | 4 +++- src/app/models/user_session.rb | 6 ++++++ src/config/application.rb | 3 ++- src/config/environments/test.rb | 2 +- 9 files changed, 20 insertions(+), 12 deletions(-)
diff --git a/src/app/controllers/application_controller.rb b/src/app/controllers/application_controller.rb index 8329459..b6159e5 100644 --- a/src/app/controllers/application_controller.rb +++ b/src/app/controllers/application_controller.rb @@ -25,13 +25,11 @@ require 'viewstate.rb' class ApplicationController < ActionController::Base # FIXME: not sure what we're doing aobut service layer w/ deltacloud include ApplicationService - filter_parameter_logging :password, :password_confirmation helper_method :current_user_session, :current_user, :filter_view? before_filter :read_breadcrumbs
def top_section; end
- # General error handlers, must be in order from least specific # to most specific rescue_from Exception, :with => :handle_general_error @@ -77,7 +75,7 @@ class ApplicationController < ActionController::Base end
def handle_error(hash) - log_error(hash[:error]) if hash[:error] + logger.fatal(hash[:error].to_s) if hash[:error] msg = hash[:message] || hash[:error].message title = hash[:title] || "Internal Server Error" status = hash[:status] || :internal_server_error @@ -199,7 +197,7 @@ class ApplicationController < ActionController::Base end
def store_location - session[:return_to] = request.request_uri + session[:return_to] = request.fullpath end
def redirect_back_or_default(default) diff --git a/src/app/models/hardware_profile.rb b/src/app/models/hardware_profile.rb index 9eb116e..57d5fd8 100644 --- a/src/app/models/hardware_profile.rb +++ b/src/app/models/hardware_profile.rb @@ -39,7 +39,7 @@
class HardwareProfile < ActiveRecord::Base has_many :instances - named_scope :frontend, :conditions => { :provider_id => nil } + scope :frontend, :conditions => { :provider_id => nil } has_many :provider_instances, :class_name => "Instance", :foreign_key => "provider_hardware_profile_id"
diff --git a/src/app/models/provider.rb b/src/app/models/provider.rb index 18df84f..1d70232 100644 --- a/src/app/models/provider.rb +++ b/src/app/models/provider.rb @@ -52,7 +52,6 @@ class Provider < ActiveRecord::Base validates_format_of :name, :with => /^[\w -]*$/n, :message => "must only contain: numbers, letters, spaces, '_' and '-'" validates_length_of :name, :maximum => 255
- has_many :permissions, :as => :permission_object, :dependent => :destroy, :include => [:role], :order => "permissions.id ASC" @@ -67,7 +66,7 @@ class Provider < ActiveRecord::Base self.provider_accounts.each do |c| unless c.instances.empty? inst_list = c.instances.map {|i| i.name}.join(', ') - self.errors.add_to_base "there are instances for cloud account '#{c.name}': #{inst_list}" + self.errors.add(:base, "there are instances for cloud account '#{c.name}': #{inst_list}") end end end @@ -95,7 +94,7 @@ class Provider < ActiveRecord::Base end
protected - def validate + def validate_provider if !nil_or_empty(url) errors.add("url", "must be a valid provider url") unless valid_framework? end diff --git a/src/app/models/quota.rb b/src/app/models/quota.rb index 9583e5f..44b25d1 100644 --- a/src/app/models/quota.rb +++ b/src/app/models/quota.rb @@ -36,6 +36,8 @@
class Quota < ActiveRecord::Base
+ set_table_name "quotas" + has_one :pool has_one :pool_family has_one :provider_account diff --git a/src/app/models/search_filter.rb b/src/app/models/search_filter.rb index 0913933..a56aab8 100644 --- a/src/app/models/search_filter.rb +++ b/src/app/models/search_filter.rb @@ -20,7 +20,7 @@ module SearchFilter def self.included(base) base.class_eval do - named_scope :search_filter, lambda {|str, cols| + scope :search_filter, lambda {|str, cols| if str.to_s.empty? {:conditions => {}} else diff --git a/src/app/models/task.rb b/src/app/models/task.rb index 15e2eb7..ac164c7 100644 --- a/src/app/models/task.rb +++ b/src/app/models/task.rb @@ -136,7 +136,9 @@ class Task < ActiveRecord::Base time_ended - time_started end
- def validate + validate :validate_task + + def validate_task errors.add("created_at", "Task started but does not have the creation time set") if time_started and created_at.nil? # Removed check on time_started exisiting. if time_ended does. This can now occur, when the task fails before is starts. e.g. When Over Qutoa #errors.add("time_started", "Task ends but does not have the start time set") if time_ended and time_started.nil? diff --git a/src/app/models/user_session.rb b/src/app/models/user_session.rb index 544ec6b..43f4547 100644 --- a/src/app/models/user_session.rb +++ b/src/app/models/user_session.rb @@ -21,4 +21,10 @@
class UserSession < Authlogic::Session::Base generalize_credentials_error_messages true + + # http://railsplugins.org/plugins/56-authlogic + def to_key + new_record? ? nil : [self.send(self.class.primary_key)] + end + end diff --git a/src/config/application.rb b/src/config/application.rb index 042dc8a..11261ac 100644 --- a/src/config/application.rb +++ b/src/config/application.rb @@ -8,7 +8,7 @@ Bundler.require(:default, Rails.env) if defined?(Bundler)
$: << File.join(File.dirname(__FILE__), "../app")
-module Aggregator +module Conductor class Application < Rails::Application # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers @@ -41,6 +41,7 @@ module Aggregator
# Configure sensitive parameters which will be filtered from the log file. config.filter_parameters += [:password, :password_confirmation] + require 'lib/warehouse_model.rb'
config.after_initialize do Haml::Template.options[:format] = :html5 diff --git a/src/config/environments/test.rb b/src/config/environments/test.rb index ba633db..f4e4baf 100644 --- a/src/config/environments/test.rb +++ b/src/config/environments/test.rb @@ -1,4 +1,4 @@ -Aggregator::Application.configure do +Conductor::Application.configure do # Settings specified here will take precedence over those in config/environment.rb
# The test environment is used exclusively to run your application's