Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

remove ActiveRecord#rails_admin

, as it is fundamentally incompatible with models mass-configuration and https://github.com/sferik/rails_admin/blob/master/lib/rails_admin/config/base.rb#L78 configuration pattern.
Guarantying order and effective execution of both initializer and model's block in both prod and dev mode can't be met easily without destroying performances in dev mode (and complexifying loader by an order of magnitude, jeopardizing RA development).

So be it, it ain't worth it. rails_admin initializer is the king of the day.
  • Loading branch information...
commit 23666da05a20826d12685087a9beee88299ba785 1 parent 9a916ea
@bbenezech bbenezech authored
View
10 README.md
@@ -32,6 +32,10 @@ Supported ORMs:
## <a name="notices">Notices</a>
+`ActiveRecord#rails_admin` is no more :(
+Please move all remaining code from your models to rails_admin initializer, it won't be evaluated.
+Incidentally, `reload_between_requests` is also no longer in use.
+
`Virtual` Class is no more. :(
Just use `String` instead, or another type. There is a `virtual?` method on `Fields::Base`, that can be used to detect whereas field has properties.
@@ -250,12 +254,6 @@ You can customize the width of the list view with:
config.total_columns_width = 1000
end
-If you don't want to reload RailsAdmin config at each requests in development mode (it can get _very_ slow):
-
- RailsAdmin.config do |config|
- config.reload_between_requests = false
- end
-
**Whitelist Approach**
By default, RailsAdmin automatically discovers all the models in the system and adds them to its list of models to
View
2  config/initializers/active_record_extensions.rb
@@ -1,7 +1,7 @@
if defined?(::ActiveRecord)
class ActiveRecord::Base
def self.rails_admin(&block)
- RailsAdmin::Config.model(self, &block)
+ ActiveSupport::Deprecation.warn("'#{self.name}.rails_admin { }' is deprecated, content is not evaluated anymore, use initializer instead", caller)
end
def rails_admin_default_object_label_method
View
6 lib/generators/rails_admin/templates/initializer.erb
@@ -44,11 +44,7 @@ RailsAdmin.config do |config|
# Default is :default
# current_user is accessible in the block if you want to make it user specific.
# config.attr_accessible_role { :default }
-
- # ==> Dev. settings
- # Reload rails_admin with each request (can be slow) in development mode
- # config.reload_between_requests = true
-
+
# ==> Global show view settings
# Display empty fields in show views
# config.compact_show_view = false
View
27 lib/rails_admin.rb
@@ -8,17 +8,6 @@
require 'rails_admin/support/core_extensions'
module RailsAdmin
- # Copy of initializer blocks for initialization
- #
- # @see RailsAdmin.setup
- @initializers = []
-
- # Whether or not the initializers have been run
- #
- # @see RailsAdmin.reset
- # @see RailsAdmin.setup
- @initialized = false
-
def self.authenticate_with(&block)
ActiveSupport::Deprecation.warn("'#{self.name}.authenticate_with { }' is deprecated, use 'RailsAdmin.config{|c| c.authenticate_with }' instead", caller)
self.config {|c| c.authenticate_with(&block) }
@@ -56,8 +45,7 @@ def self.config(entity = nil, &block)
if entity
RailsAdmin::Config.model(entity, &block)
elsif block_given?
- @initializers << block
- block.call(RailsAdmin::Config) if @initialized
+ block.call(RailsAdmin::Config)
else
RailsAdmin::Config
end
@@ -66,18 +54,5 @@ def self.config(entity = nil, &block)
# Reset RailsAdmin configuration to defaults
def self.reset
RailsAdmin::Config.reset
- @initialized = false
- end
-
- # Apply all initializers stored on application startup
- def self.setup
- @initializers.each {|block| block.call(RailsAdmin::Config) } unless @initialized
- @initialized = true
- end
-
- # Reset RailsAdmin including initializers
- def self.test_reset!
- self.reset
- @initializers.clear
end
end
View
10 lib/rails_admin/config.rb
@@ -50,9 +50,6 @@ class AuthenticationNotConfigured < StandardError; end
class << self
# Application title, can be an array of two elements
attr_accessor :main_app_name
-
- # in development mode, setting this to true will make rails_admin reload the whole configuration at each request
- attr_accessor :reload_between_requests
# Configuration option to specify which models you want to exclude.
attr_accessor :excluded_models
@@ -200,7 +197,11 @@ def default_search_operator=(operator)
raise ArgumentError, "Search operator '#{operator}' not supported"
end
end
-
+
+ def reload_between_requests=(thingy)
+ ActiveSupport::Deprecation.warn("'#{self.name}.reload_between_requests=' is not in use any longer, please remove it from initialization files", caller)
+ end
+
# Shortcut to access the list section's class configuration
# within a config DSL block
#
@@ -262,7 +263,6 @@ def navigation
#
# @see RailsAdmin::Config.registry
def reset
- @reload_between_requests = false
@compact_show_view = true
@authenticate = nil
@authorize = nil
View
10 lib/rails_admin/engine.rb
@@ -4,15 +4,5 @@
module RailsAdmin
class Engine < Rails::Engine
isolate_namespace RailsAdmin
-
- ActionDispatch::Callbacks.before do
- RailsAdmin.setup
- end
-
- initializer "rails admin development mode" do |app|
- ActionDispatch::Callbacks.after do
- RailsAdmin.reset if !app.config.cache_classes && RailsAdmin.config.reload_between_requests
- end
- end
end
end
View
3  spec/spec_helper.rb
@@ -60,7 +60,6 @@ def password_digest(password)
config.include Warden::Test::Helpers
config.before(:each) do
- RailsAdmin.setup
RailsAdmin::Config.excluded_models = [RelTest, FieldTest]
RailsAdmin::AbstractModel.all_models = nil
RailsAdmin::AbstractModel.all_abstract_models = nil
@@ -83,7 +82,7 @@ def password_digest(password)
end
config.after(:each) do
- RailsAdmin.test_reset!
+ RailsAdmin.reset
Warden.test_reset!
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.