Permalink
Browse files

Autocorrect all autocorrectable offenses

  • Loading branch information...
1 parent 71d6443 commit 03431bcb8f1778d273f8f11d93153e35905085ac @sferik committed Feb 1, 2014
Showing with 3,728 additions and 3,830 deletions.
  1. +0 −1 .travis.yml
  2. +8 −8 Gemfile
  3. +2 −2 Rakefile
  4. +12 −12 app/controllers/rails_admin/application_controller.rb
  5. +30 −35 app/controllers/rails_admin/main_controller.rb
  6. +36 −39 app/helpers/rails_admin/application_helper.rb
  7. +26 −25 app/helpers/rails_admin/form_builder.rb
  8. +10 −9 app/helpers/rails_admin/main_helper.rb
  9. +3 −3 config/initializers/active_record_extensions.rb
  10. +1 −1 config/initializers/haml.rb
  11. +7 −7 config/routes.rb
  12. +5 −5 lib/generators/rails_admin/install_generator.rb
  13. +1 −1 lib/generators/rails_admin/templates/initializer.erb
  14. +4 −3 lib/generators/rails_admin/utils.rb
  15. +29 −27 lib/rails_admin/abstract_model.rb
  16. +36 −36 lib/rails_admin/adapters/active_record.rb
  17. +2 −2 lib/rails_admin/adapters/active_record/abstract_object.rb
  18. +100 −106 lib/rails_admin/adapters/mongoid.rb
  19. +1 −1 lib/rails_admin/adapters/mongoid/abstract_object.rb
  20. +5 −5 lib/rails_admin/adapters/mongoid/extension.rb
  21. +7 −8 lib/rails_admin/bootstrap-sass.rb
  22. +2 −1 lib/rails_admin/bootstrap-sass/compass_functions.rb
  23. +23 −23 lib/rails_admin/config.rb
  24. +12 −15 lib/rails_admin/config/actions.rb
  25. +8 −8 lib/rails_admin/config/actions/base.rb
  26. +3 −3 lib/rails_admin/config/actions/bulk_delete.rb
  27. +5 −5 lib/rails_admin/config/actions/dashboard.rb
  28. +4 −4 lib/rails_admin/config/actions/delete.rb
  29. +3 −3 lib/rails_admin/config/actions/edit.rb
  30. +1 −1 lib/rails_admin/config/actions/export.rb
  31. +1 −1 lib/rails_admin/config/actions/history_index.rb
  32. +1 −1 lib/rails_admin/config/actions/history_show.rb
  33. +11 −12 lib/rails_admin/config/actions/index.rb
  34. +3 −3 lib/rails_admin/config/actions/new.rb
  35. +2 −2 lib/rails_admin/config/actions/show.rb
  36. +1 −1 lib/rails_admin/config/actions/show_in_app.rb
  37. +26 −26 lib/rails_admin/config/configurable.rb
  38. +7 −7 lib/rails_admin/config/fields.rb
  39. +5 −6 lib/rails_admin/config/fields/association.rb
  40. +32 −30 lib/rails_admin/config/fields/base.rb
  41. +9 −10 lib/rails_admin/config/fields/factories/association.rb
  42. +3 −9 lib/rails_admin/config/fields/factories/carrierwave.rb
  43. +2 −4 lib/rails_admin/config/fields/factories/devise.rb
  44. +3 −5 lib/rails_admin/config/fields/factories/dragonfly.rb
  45. +1 −1 lib/rails_admin/config/fields/factories/enum.rb
  46. +3 −3 lib/rails_admin/config/fields/factories/paperclip.rb
  47. +6 −8 lib/rails_admin/config/fields/group.rb
  48. +2 −2 lib/rails_admin/config/fields/types.rb
  49. +4 −4 lib/rails_admin/config/fields/types/belongs_to_association.rb
  50. +2 −2 lib/rails_admin/config/fields/types/boolean.rb
  51. +7 −12 lib/rails_admin/config/fields/types/bson_object_id.rb
  52. +1 −1 lib/rails_admin/config/fields/types/carrierwave.rb
  53. +3 −3 lib/rails_admin/config/fields/types/ck_editor.rb
  54. +9 −9 lib/rails_admin/config/fields/types/code_mirror.rb
  55. +2 −2 lib/rails_admin/config/fields/types/color.rb
  56. +2 −2 lib/rails_admin/config/fields/types/date.rb
  57. +52 −54 lib/rails_admin/config/fields/types/datetime.rb
  58. +1 −1 lib/rails_admin/config/fields/types/decimal.rb
  59. +2 −2 lib/rails_admin/config/fields/types/dragonfly.rb
  60. +3 −3 lib/rails_admin/config/fields/types/enum.rb
  61. +5 −5 lib/rails_admin/config/fields/types/file_upload.rb
  62. +1 −1 lib/rails_admin/config/fields/types/float.rb
  63. +1 −1 lib/rails_admin/config/fields/types/has_and_belongs_to_many_association.rb
  64. +1 −1 lib/rails_admin/config/fields/types/has_many_association.rb
  65. +3 −4 lib/rails_admin/config/fields/types/has_one_association.rb
  66. +1 −1 lib/rails_admin/config/fields/types/hidden.rb
  67. +1 −1 lib/rails_admin/config/fields/types/integer.rb
  68. +2 −2 lib/rails_admin/config/fields/types/paperclip.rb
  69. +4 −4 lib/rails_admin/config/fields/types/password.rb
  70. +8 −11 lib/rails_admin/config/fields/types/polymorphic_association.rb
  71. +1 −1 lib/rails_admin/config/fields/types/serialized.rb
  72. +5 −6 lib/rails_admin/config/fields/types/string.rb
  73. +6 −6 lib/rails_admin/config/fields/types/text.rb
  74. +4 −4 lib/rails_admin/config/fields/types/time.rb
  75. +1 −1 lib/rails_admin/config/fields/types/timestamp.rb
  76. +1 −2 lib/rails_admin/config/fields/types/wysihtml5.rb
  77. +24 −24 lib/rails_admin/config/has_fields.rb
  78. +3 −3 lib/rails_admin/config/has_groups.rb
  79. +2 −2 lib/rails_admin/config/hideable.rb
  80. +1 −1 lib/rails_admin/config/lazy_model.rb
  81. +6 −7 lib/rails_admin/config/model.rb
  82. +4 −6 lib/rails_admin/config/proxyable/proxy.rb
  83. +1 −3 lib/rails_admin/config/sections.rb
  84. +1 −1 lib/rails_admin/config/sections/base.rb
  85. +3 −3 lib/rails_admin/engine.rb
  86. +3 −3 lib/rails_admin/extension.rb
  87. +3 −3 lib/rails_admin/extensions/cancan.rb
  88. +1 −1 lib/rails_admin/extensions/cancan/authorization_adapter.rb
  89. +3 −3 lib/rails_admin/extensions/history.rb
  90. +1 −1 lib/rails_admin/extensions/history/auditing_adapter.rb
  91. +12 −11 lib/rails_admin/extensions/history/history.rb
  92. +3 −3 lib/rails_admin/extensions/paper_trail.rb
  93. +21 −20 lib/rails_admin/extensions/paper_trail/auditing_adapter.rb
  94. +11 −15 lib/rails_admin/i18n_support.rb
  95. +4 −5 lib/rails_admin/support/core_extensions.rb
  96. +21 −23 lib/rails_admin/support/csv_converter.rb
  97. +0 −3 lib/rails_admin/version.rb
  98. +3 −3 rails_admin.gemspec
  99. +12 −12 spec/controllers/rails_admin/application_controller_spec.rb
  100. +127 −130 spec/controllers/rails_admin/main_controller_spec.rb
  101. +4 −4 spec/dummy_app/Gemfile
  102. +0 −2 spec/dummy_app/app/active_record/abstract.rb
  103. +1 −1 spec/dummy_app/app/active_record/another_field_test.rb
  104. +2 −2 spec/dummy_app/app/active_record/ball.rb
  105. +1 −3 spec/dummy_app/app/active_record/carrierwave_uploader.rb
  106. +1 −1 spec/dummy_app/app/active_record/category.rb
  107. +1 −1 spec/dummy_app/app/active_record/cms/basic_page.rb
  108. +1 −1 spec/dummy_app/app/active_record/comment.rb
  109. +1 −1 spec/dummy_app/app/active_record/comment/confirmed.rb
  110. +2 −2 spec/dummy_app/app/active_record/division.rb
  111. +5 −5 spec/dummy_app/app/active_record/draft.rb
  112. +6 −6 spec/dummy_app/app/active_record/field_test.rb
  113. +1 −1 spec/dummy_app/app/active_record/image.rb
  114. +3 −3 spec/dummy_app/app/active_record/league.rb
  115. +4 −4 spec/dummy_app/app/active_record/nested_field_test.rb
  116. +7 −7 spec/dummy_app/app/active_record/player.rb
  117. +9 −10 spec/dummy_app/app/active_record/team.rb
  118. +2 −2 spec/dummy_app/app/active_record/user.rb
  119. +1 −1 spec/dummy_app/app/mongoid/another_field_test.rb
  120. +3 −3 spec/dummy_app/app/mongoid/ball.rb
  121. +1 −3 spec/dummy_app/app/mongoid/carrierwave_uploader.rb
  122. +1 −1 spec/dummy_app/app/mongoid/category.rb
  123. +3 −3 spec/dummy_app/app/mongoid/cms/basic_page.rb
  124. +2 −2 spec/dummy_app/app/mongoid/comment.rb
  125. +1 −1 spec/dummy_app/app/mongoid/comment/confirmed.rb
  126. +2 −2 spec/dummy_app/app/mongoid/division.rb
  127. +11 −11 spec/dummy_app/app/mongoid/draft.rb
  128. +1 −1 spec/dummy_app/app/mongoid/embed.rb
  129. +1 −1 spec/dummy_app/app/mongoid/fan.rb
  130. +35 −35 spec/dummy_app/app/mongoid/field_test.rb
  131. +1 −1 spec/dummy_app/app/mongoid/image.rb
  132. +3 −3 spec/dummy_app/app/mongoid/league.rb
  133. +5 −5 spec/dummy_app/app/mongoid/nested_field_test.rb
  134. +17 −17 spec/dummy_app/app/mongoid/player.rb
  135. +25 −25 spec/dummy_app/app/mongoid/team.rb
  136. +13 −13 spec/dummy_app/app/mongoid/user.rb
  137. +4 −4 spec/dummy_app/config/application.rb
  138. +1 −3 spec/dummy_app/config/boot.rb
  139. +1 −1 spec/dummy_app/config/environments/test.rb
  140. +2 −2 spec/dummy_app/config/initializers/devise.rb
  141. +1 −2 spec/dummy_app/config/initializers/session_patch.rb
  142. +1 −1 spec/dummy_app/config/initializers/session_store.rb
  143. +1 −1 spec/dummy_app/config/initializers/wrap_parameters.rb
  144. +2 −2 spec/dummy_app/config/routes.rb
  145. +1 −1 spec/dummy_app/db/migrate/00000000000001_create_divisions_migration.rb
  146. +1 −1 spec/dummy_app/db/migrate/00000000000002_create_drafts_migration.rb
  147. +1 −1 spec/dummy_app/db/migrate/00000000000003_create_leagues_migration.rb
  148. +5 −5 spec/dummy_app/db/migrate/00000000000004_create_players_migration.rb
  149. +5 −5 spec/dummy_app/db/migrate/00000000000005_create_teams_migration.rb
  150. +5 −5 spec/dummy_app/db/migrate/00000000000006_devise_create_users.rb
  151. +7 −7 spec/dummy_app/db/migrate/00000000000007_create_histories_table.rb
  152. +1 −1 spec/dummy_app/db/migrate/00000000000008_create_fans_migration.rb
  153. +1 −1 spec/dummy_app/db/migrate/00000000000009_create_fans_teams_migration.rb
  154. +1 −1 spec/dummy_app/db/migrate/00000000000010_add_revenue_to_team_migration.rb
  155. +1 −1 spec/dummy_app/db/migrate/00000000000011_add_suspended_to_player_migration.rb
  156. +0 −1 spec/dummy_app/db/migrate/00000000000012_add_avatar_columns_to_user.rb
  157. +1 −1 spec/dummy_app/db/migrate/20101223222233_create_rel_tests.rb
  158. +1 −1 spec/dummy_app/db/migrate/20110714095433_create_balls.rb
  159. +3 −3 spec/dummy_app/db/migrate/20110901131551_change_division_primary_key.rb
  160. +4 −5 spec/dummy_app/db/migrate/20110901150912_set_primary_key_not_null_for_divisions.rb
  161. +1 −1 spec/dummy_app/db/migrate/20120319041705_drop_rel_tests.rb
  162. +9 −9 spec/dummy_app/db/seeds.rb
  163. +2 −3 spec/factories.rb
  164. +86 −86 spec/helpers/rails_admin/application_helper_spec.rb
  165. +6 −6 spec/helpers/rails_admin/form_builder_spec.rb
  166. +167 −174 spec/integration/authorization/cancan_spec.rb
  167. +11 −11 spec/integration/basic/bulk_action/rails_admin_basic_bulk_action_spec.rb
  168. +16 −16 spec/integration/basic/bulk_destroy/rails_admin_basic_bulk_destroy_spec.rb
  169. +69 −69 spec/integration/basic/create/rails_admin_basic_create_spec.rb
  170. +8 −8 spec/integration/basic/create/rails_admin_namespaced_model_create_spec.rb
  171. +21 −21 spec/integration/basic/delete/rails_admin_basic_delete_spec.rb
  172. +32 −32 spec/integration/basic/destroy/rails_admin_basic_destroy_spec.rb
  173. +39 −39 spec/integration/basic/edit/rails_admin_basic_edit_spec.rb
  174. +36 −36 spec/integration/basic/export/rails_admin_basic_export_spec.rb
  175. +144 −146 spec/integration/basic/list/rails_admin_basic_list_spec.rb
  176. +30 −30 spec/integration/basic/new/rails_admin_basic_new_spec.rb
  177. +12 −12 spec/integration/basic/new/rails_admin_namespaced_model_new_spec.rb
  178. +34 −34 spec/integration/basic/show/rails_admin_basic_show_spec.rb
  179. +90 −90 spec/integration/basic/update/rails_admin_basic_update_spec.rb
  180. +351 −352 spec/integration/config/edit/rails_admin_config_edit_spec.rb
  181. +132 −133 spec/integration/config/list/rails_admin_config_list_spec.rb
  182. +82 −83 spec/integration/config/show/rails_admin_config_show_spec.rb
  183. +15 −15 spec/integration/history/rails_admin_history_spec.rb
  184. +43 −43 spec/integration/rails_admin_spec.rb
  185. +12 −12 spec/integration/relation_spec.rb
  186. +7 −4 spec/orm/active_record.rb
  187. +1 −7 spec/orm/mongoid.rb
  188. +28 −28 spec/rails_admin/abstract_model_spec.rb
  189. +3 −3 spec/rails_admin/active_record_extension_spec.rb
  190. +29 −29 spec/rails_admin/adapters/active_record/abstract_object_spec.rb
  191. +210 −215 spec/rails_admin/adapters/active_record_spec.rb
  192. +19 −19 spec/rails_admin/adapters/mongoid/abstract_object_spec.rb
  193. +429 −435 spec/rails_admin/adapters/mongoid_spec.rb
  194. +9 −9 spec/rails_admin/config/actions/base_spec.rb
  195. +42 −42 spec/rails_admin/config/actions_spec.rb
  196. +135 −136 spec/rails_admin/config/fields/base_spec.rb
  197. +17 −17 spec/rails_admin/config/fields/date_spec.rb
  198. +12 −13 spec/rails_admin/config/fields/datetime_spec.rb
  199. +4 −5 spec/rails_admin/config/fields/file_upload_spec.rb
  200. +12 −13 spec/rails_admin/config/fields/time_spec.rb
  201. +5 −5 spec/rails_admin/config/fields/timestamp_spec.rb
  202. +1 −1 spec/rails_admin/config/fields/types/ck_editor_spec.rb
  203. +2 −2 spec/rails_admin/config/fields/types/datetime_spec.rb
  204. +4 −4 spec/rails_admin/config/fields_spec.rb
  205. +4 −4 spec/rails_admin/config/has_fields_spec.rb
  206. +5 −5 spec/rails_admin/config/lazy_model_spec.rb
  207. +50 −50 spec/rails_admin/config/model_spec.rb
  208. +7 −10 spec/rails_admin/config/proxyable/proxy_spec.rb
  209. +22 −22 spec/rails_admin/config/sections_spec.rb
  210. +79 −80 spec/rails_admin/config_spec.rb
  211. +3 −3 spec/rails_admin/support/csv_converter_spec.rb
  212. +6 −6 spec/spec_helper.rb
View
@@ -39,4 +39,3 @@ before_script:
- cd ../../
services:
- mongodb
-script: bundle exec rake default
View
16 Gemfile
@@ -28,10 +28,10 @@ group :active_record do
end
group :mongoid do
- gem 'mongoid', :github => 'mongoid/mongoid'
- gem 'mongoid-paperclip', '>= 0.0.8', :require => 'mongoid_paperclip'
- gem 'mongoid-grid_fs', :github => 'ahoward/mongoid-grid_fs'
- gem 'carrierwave-mongoid', '>= 0.6.3', :require => 'carrierwave/mongoid'
+ gem 'mongoid', github: 'mongoid/mongoid'
+ gem 'mongoid-paperclip', '>= 0.0.8', require: 'mongoid_paperclip'
+ gem 'mongoid-grid_fs', github: 'ahoward/mongoid-grid_fs'
+ gem 'carrierwave-mongoid', '>= 0.6.3', require: 'carrierwave/mongoid'
end
group :development, :test do
@@ -47,7 +47,7 @@ group :test do
gem 'cancan', '>= 1.6'
gem 'capybara', '>= 2.1'
gem 'carrierwave', '>= 0.8'
- gem 'coveralls', :require => false
+ gem 'coveralls', require: false
gem 'database_cleaner', '>= 1.2'
gem 'devise', '>= 3.2'
gem 'dragonfly', '~> 0.9.0'
@@ -56,11 +56,11 @@ group :test do
gem 'launchy', '>= 2.2'
gem 'mini_magick', '>= 3.4'
gem 'paperclip', '>= 3.4'
- gem 'poltergeist', :github => 'jonleighton/poltergeist'
- gem 'rack-cache', :require => 'rack/cache'
+ gem 'poltergeist', github: 'jonleighton/poltergeist'
+ gem 'rack-cache', require: 'rack/cache'
gem 'rspec-rails', '>= 2.14'
gem 'rubocop', '>= 0.15'
- gem 'simplecov', :require => false
+ gem 'simplecov', require: false
gem 'timecop', '>= 0.5'
end
View
@@ -9,7 +9,7 @@ Bundler::GemHelper.install_tasks
require 'rspec/core/rake_task'
RSpec::Core::RakeTask.new(:spec)
-task :test => :spec
+task test: :spec
begin
require 'rubocop/rake_task'
@@ -21,4 +21,4 @@ rescue LoadError
end
end
-task :default => [:spec, :rubocop]
+task default: [:spec, :rubocop]
@@ -20,57 +20,57 @@ class ApplicationController < ::ApplicationController
def get_model
@model_name = to_model_name(params[:model_name])
- raise RailsAdmin::ModelNotFound unless (@abstract_model = RailsAdmin::AbstractModel.new(@model_name))
- raise RailsAdmin::ModelNotFound if (@model_config = @abstract_model.config).excluded?
+ fail(RailsAdmin::ModelNotFound) unless (@abstract_model = RailsAdmin::AbstractModel.new(@model_name))
+ fail(RailsAdmin::ModelNotFound) if (@model_config = @abstract_model.config).excluded?
@properties = @abstract_model.properties
end
def get_object
- raise RailsAdmin::ObjectNotFound unless (@object = @abstract_model.get(params[:id]))
+ fail(RailsAdmin::ObjectNotFound) unless (@object = @abstract_model.get(params[:id]))
end
def to_model_name(param)
- model_name = param.split("~").map(&:camelize).join("::")
+ param.split('~').collect(&:camelize).join('::')
end
- private
+ private
def _get_plugin_name
@plugin_name_array ||= [RailsAdmin.config.main_app_name.is_a?(Proc) ? instance_eval(&RailsAdmin.config.main_app_name) : RailsAdmin.config.main_app_name].flatten
end
def _authenticate!
- instance_eval &RailsAdmin::Config.authenticate_with
+ instance_eval(&RailsAdmin::Config.authenticate_with)
end
def _authorize!
- instance_eval &RailsAdmin::Config.authorize_with
+ instance_eval(&RailsAdmin::Config.authorize_with)
end
def _audit!
- instance_eval &RailsAdmin::Config.audit_with
+ instance_eval(&RailsAdmin::Config.audit_with)
end
def _current_user
- instance_eval &RailsAdmin::Config.current_user_method
+ instance_eval(&RailsAdmin::Config.current_user_method)
end
alias_method :user_for_paper_trail, :_current_user
rescue_from RailsAdmin::ObjectNotFound do
- flash[:error] = I18n.t('admin.flash.object_not_found', :model => @model_name, :id => params[:id])
+ flash[:error] = I18n.t('admin.flash.object_not_found', model: @model_name, id: params[:id])
params[:action] = 'index'
index
end
rescue_from RailsAdmin::ModelNotFound do
- flash[:error] = I18n.t('admin.flash.model_not_found', :model => @model_name)
+ flash[:error] = I18n.t('admin.flash.model_not_found', model: @model_name)
params[:action] = 'dashboard'
dashboard
end
def not_found
- render :file => Rails.root.join('public', '404.html'), :layout => false, :status => :not_found
+ render file: Rails.root.join('public', '404.html'), layout: false, status: :not_found
end
def rails_admin_controller?
@@ -1,15 +1,13 @@
module RailsAdmin
-
class MainController < RailsAdmin::ApplicationController
-
include ActionView::Helpers::TextHelper
include RailsAdmin::MainHelper
include RailsAdmin::ApplicationHelper
layout :get_layout
- before_filter :get_model, :except => RailsAdmin::Config::Actions.all(:root).map(&:action_name)
- before_filter :get_object, :only => RailsAdmin::Config::Actions.all(:member).map(&:action_name)
+ before_filter :get_model, except: RailsAdmin::Config::Actions.all(:root).collect(&:action_name)
+ before_filter :get_object, only: RailsAdmin::Config::Actions.all(:member).collect(&:action_name)
before_filter :check_for_cancel
RailsAdmin::Config::Actions.all.each do |action|
@@ -26,7 +24,7 @@ def #{action.action_name}
end
def bulk_action
- self.send(params[:bulk_action]) if params[:bulk_action].in?(RailsAdmin::Config::Actions.all(:controller => self, :abstract_model => @abstract_model).select(&:bulkable?).map(&:route_fragment))
+ send(params[:bulk_action]) if params[:bulk_action].in?(RailsAdmin::Config::Actions.all(controller: self, abstract_model: @abstract_model).select(&:bulkable?).collect(&:route_fragment))
end
def list_entries(model_config = @model_config, auth_scope_key = :index, additional_scope = get_association_scope_from_params, pagination = !(params[:associated_collection] || params[:all] || params[:bulk_ids]))
@@ -39,7 +37,7 @@ def list_entries(model_config = @model_config, auth_scope_key = :index, addition
get_collection(model_config, scope, pagination)
end
- private
+ private
def get_layout
"rails_admin/#{request.headers['X-PJAX'] ? 'pjax' : 'application'}"
@@ -51,12 +49,12 @@ def back_or_index
def get_sort_hash(model_config)
abstract_model = model_config.abstract_model
- params[:sort] = params[:sort_reverse] = nil unless model_config.list.fields.map {|f| f.name.to_s}.include? params[:sort]
+ params[:sort] = params[:sort_reverse] = nil unless model_config.list.fields.collect { |f| f.name.to_s }.include? params[:sort]
params[:sort] ||= model_config.list.sort_by.to_s
params[:sort_reverse] ||= 'false'
- field = model_config.list.fields.find{ |f| f.name.to_s == params[:sort] }
+ field = model_config.list.fields.detect { |f| f.name.to_s == params[:sort] }
column = if field.nil? || field.sortable == true # use params[:sort] on the base table
"#{abstract_model.table_name}.#{params[:sort]}"
@@ -73,33 +71,33 @@ def get_sort_hash(model_config)
end
reversed_sort = (field ? field.sort_reverse? : model_config.list.sort_reverse?)
- {:sort => column, :sort_reverse => (params[:sort_reverse] == reversed_sort.to_s)}
+ {sort: column, sort_reverse: (params[:sort_reverse] == reversed_sort.to_s)}
end
def redirect_to_on_success
- notice = t("admin.flash.successful", :name => @model_config.label, :action => t("admin.actions.#{@action.key}.done"))
+ notice = t('admin.flash.successful', name: @model_config.label, action: t("admin.actions.#{@action.key}.done"))
if params[:_add_another]
- redirect_to new_path(:return_to => params[:return_to]), :flash => { :success => notice }
+ redirect_to new_path(return_to: params[:return_to]), flash: {success: notice}
elsif params[:_add_edit]
- redirect_to edit_path(:id => @object.id, :return_to => params[:return_to]), :flash => { :success => notice }
+ redirect_to edit_path(id: @object.id, return_to: params[:return_to]), flash: {success: notice}
else
- redirect_to back_or_index, :flash => { :success => notice }
+ redirect_to back_or_index, flash: {success: notice}
end
end
def satisfy_strong_params!
- if @abstract_model.model.ancestors.map(&:to_s).include?('ActiveModel::ForbiddenAttributesProtection')
+ if @abstract_model.model.ancestors.collect(&:to_s).include?('ActiveModel::ForbiddenAttributesProtection')
params[@abstract_model.param_key].try :permit!
end
end
def sanitize_params_for!(action, model_config = @model_config, _params = params[@abstract_model.param_key])
return unless _params.present?
- fields = model_config.send(action).with(:controller => self, :view => self.view_context, :object => @object).visible_fields
- allowed_methods = fields.map{|f|
+ fields = model_config.send(action).with(controller: self, view: view_context, object: @object).visible_fields
+ allowed_methods = fields.collect do|f|
f.allowed_methods
- }.flatten.uniq.map(&:to_s) << "id" << "_destroy"
- fields.each {|f| f.parse_input(_params) }
+ end.flatten.uniq.collect(&:to_s) << 'id' << '_destroy'
+ fields.each { |f| f.parse_input(_params) }
_params.slice!(*allowed_methods)
fields.select(&:nested_form).each do |association|
children_params = association.multiple? ? _params[association.method_name].try(:values) : [_params[association.method_name]].compact
@@ -109,44 +107,41 @@ def sanitize_params_for!(action, model_config = @model_config, _params = params[
end
end
- def handle_save_error whereto = :new
- action = params[:action]
-
- flash.now[:error] = t("admin.flash.error", :name => @model_config.label, :action => t("admin.actions.#{@action.key}.done"))
+ def handle_save_error(whereto = :new)
+ flash.now[:error] = t('admin.flash.error', name: @model_config.label, action: t("admin.actions.#{@action.key}.done"))
flash.now[:error] += ". #{@object.errors[:base].to_sentence}" unless @object.errors[:base].blank?
respond_to do |format|
- format.html { render whereto, :status => :not_acceptable }
- format.js { render whereto, :layout => false, :status => :not_acceptable }
+ format.html { render whereto, status: :not_acceptable }
+ format.js { render whereto, layout: false, status: :not_acceptable }
end
end
def check_for_cancel
if params[:_continue] || (params[:bulk_action] && !params[:bulk_ids])
- redirect_to(back_or_index, :flash => { :info => t("admin.flash.noaction") })
+ redirect_to(back_or_index, flash: {info: t('admin.flash.noaction')})
end
end
def get_collection(model_config, scope, pagination)
- associations = model_config.list.fields.select {|f| f.type == :belongs_to_association && !f.polymorphic? }.map {|f| f.association[:name] }
+ associations = model_config.list.fields.select { |f| f.type == :belongs_to_association && !f.polymorphic? }.collect { |f| f.association[:name] }
options = {}
- options = options.merge(:page => (params[Kaminari.config.param_name] || 1).to_i, :per => (params[:per] || model_config.list.items_per_page)) if pagination
- options = options.merge(:include => associations) unless associations.blank?
+ options = options.merge(page: (params[Kaminari.config.param_name] || 1).to_i, per: (params[:per] || model_config.list.items_per_page)) if pagination
+ options = options.merge(include: associations) unless associations.blank?
options = options.merge(get_sort_hash(model_config))
- options = options.merge(:query => params[:query]) if params[:query].present?
- options = options.merge(:filters => params[:f]) if params[:f].present?
- options = options.merge(:bulk_ids => params[:bulk_ids]) if params[:bulk_ids]
-
- objects = model_config.abstract_model.all(options, scope)
+ options = options.merge(query: params[:query]) if params[:query].present?
+ options = options.merge(filters: params[:f]) if params[:f].present?
+ options = options.merge(bulk_ids: params[:bulk_ids]) if params[:bulk_ids]
+ model_config.abstract_model.all(options, scope)
end
def get_association_scope_from_params
return nil unless params[:associated_collection].present?
source_abstract_model = RailsAdmin::AbstractModel.new(to_model_name(params[:source_abstract_model]))
source_model_config = source_abstract_model.config
source_object = source_abstract_model.get(params[:source_object_id])
- action = params[:current_action].in?(['create', 'update']) ? params[:current_action] : 'edit'
- @association = source_model_config.send(action).fields.find{|f| f.name == params[:associated_collection].to_sym }.with(:controller => self, :object => source_object)
+ action = params[:current_action].in?(%w(create update)) ? params[:current_action] : 'edit'
+ @association = source_model_config.send(action).fields.detect { |f| f.name == params[:associated_collection].to_sym }.with(controller: self, object: source_object)
@association.associated_collection_scope
end
end
Oops, something went wrong.

0 comments on commit 03431bc

Please sign in to comment.