railsadminteam / rails_admin

RailsAdmin is a Rails engine that provides an easy-to-use interface for managing your data
MIT License
7.9k stars 2.26k forks source link

rails_admin_nestable: Changes not saved? #2825

Closed StarWar closed 5 years ago

StarWar commented 7 years ago

I have a Model and a position field with index, I want to sort this list. It worked great on my local machine but it didn't work on heroku until I tried several times and restarted app, it suddenly worked. Should I not have index on position(integer) field?

There are lots of memory quota errors

Error R14 (Memory quota exceeded)
2017-01-30T10:06:01+00:00 app[heroku-postgres]: source=HEROKU_POSTGRESQL_GREEN sample#current_transaction=2343 sample#db_size=11205144.0bytes sample#tables=23 sample#active-connections=4 sample#waiting-connections=0 sample#index-cache-hit-rate=0.98124 sample#table-cache-hit-rate=0.99547 sample#load-avg-1m=0 sample#load-avg-5m=0 sample#load-avg-15m=0 sample#read-iops=0 sample#write-iops=0.029167 sample#memory-total=4045048.0000000005kB sample#memory-free=1954188.0kB sample#memory-cached=1629768.0kB sample#memory-postgres=23652kB
2017-01-30T10:06:27.955427+00:00 heroku[web.1]: Process running mem=553M(108.1%)
2017-01-30T10:06:27.955517+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2017-01-30T10:06:50.129575+00:00 heroku[web.1]: Process running mem=553M(108.1%)
2017-01-30T10:06:50.129703+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2017-01-30T10:07:12.066037+00:00 heroku[web.1]: Process running mem=553M(108.2%)
2017-01-30T10:07:12.066164+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)
2017-01-30T10:07:34.282403+00:00 heroku[web.1]: Process running mem=553M(108.2%)
2017-01-30T10:07:34.282403+00:00 heroku[web.1]: Error R14 (Memory quota exceeded)

Here are my config files redis.rb

$redis = if ENV['REDISCLOUD_URL']
           Redis.new(url: ENV['REDISCLOUD_URL'])
         else
           Redis.new(url: ENV['REDIS_URL'])
         end

resque.rb

Resque.redis = $redis

Resque.before_fork do
  defined?(ActiveRecord::Base) &&
    ActiveRecord::Base.connection.disconnect!
end

Resque.after_fork do
  defined?(ActiveRecord::Base) &&
    ActiveRecord::Base.establish_connection
end

puma.rb

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  # Worker specific setup for Rails 4.1+
  # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot
  ActiveRecord::Base.establish_connection

  if ENV["REDISCLOUD_URL"]
    Redis.current = Redis.new(url: ENV['REDISCLOUD_URL'])
    $redis = Redis.current
  elsif ENV['REDIS_URL']
    Redis.current = Redis.new(url: ENV['REDIS_URL'])
    $redis = Redis.current
  else
    Redis.current.quit
  end

  if defined?(Resque)
    Resque.redis = $redis
  end
end

And relevant portion of rails_admin.rb

config.actions do
    # root actions
    dashboard # mandatory
    # collection actions
    index # mandatory
    new
    export
    bulk_delete
    # member actions
    toggle
    show
    edit
    delete
    show_in_app

    nestable
end

config.model 'State' do
    nestable_list true

    list do
      sort_by :position
      field :position do
        sortable true
      end
      field :name
      field :state_type do
        visible true
        searchable false
      end
   end
end
mshibuya commented 5 years ago

Please use StackOverflow for the support request, thanks.