app/models/role.rb in usman-0.1.4 vs app/models/role.rb in usman-0.1.5dev

- old
+ new

@@ -1,10 +1,7 @@ class Role < Usman::ApplicationRecord - require 'import_error_handler.rb' - extend Usman::ImportErrorHandler - # Associations has_and_belongs_to_many :users # Validations validates :name, presence: true @@ -16,23 +13,23 @@ # return an active record relation object with the search query in its where clause # Return the ActiveRecord::Relation object # == Examples # >>> role.search(query) # => ActiveRecord::Relation object - scope :search, lambda {|query| where("LOWER(name) LIKE LOWER('%#{query}%')") + scope :search, lambda {|query| where("LOWER(roles.name) LIKE LOWER('%#{query}%')") } - def self.save_row_data(row, base_path) + def self.save_row_data(row) row.headers.each{ |cell| row[cell] = row[cell].to_s.strip } return if row[:name].blank? role = Role.find_by_name(row[:name]) || Role.new role.name = row[:name] # Initializing error hash for displaying all errors altogether - error_object = Usman::ErrorHash.new + error_object = Kuppayam::Importer::ErrorHash.new if role.valid? role.save! else summary = "Error while saving role: #{role.name}" \ No newline at end of file