Code Monkey home page Code Monkey logo

rails_admin_nestable's Introduction

Rails Admin Nestable

RailsAdmin Drag and drop tree view for Ancestry and mongoid-ancestry gem

Sample demo available at: https://github.com/dalpo/rails_admin_nestable_demo

Gem Version Code Climate

Installation

To enable rails_admin_nestable, add the following to your Gemfile:

gem 'rails_admin_nestable', '~> 0.3.2'

Add in your config/initializers/rails_admin.rb initializer the configuration:

RailsAdmin.config do |config|
  config.actions do
    # root actions
    dashboard                     # mandatory
    # collection actions
    index                         # mandatory
    new
    export
    history_index
    bulk_delete
    # member actions
    show
    edit
    delete
    history_show
    show_in_app

    # Add the nestable action for configured models
    nestable
  end
end

Configuration

You could choose between two different configurations for your model:

1. Nestable tree:

To use this configuration, you need to organize your tree model with Ancestry or Mongoid Ancestry. Otherwise your model have to respond to the parent, arrange and children methods.

The nestable_tree methods supports the following options:

  • position_field: (symbol) default => nil
  • max_depth: (integer) default => nil
  • enable_callback: (boolean) default => false
  • scope: (symbol | proc) default => nil
  • live_update: (boolean | :only) default => true (:only is for live updating only)

In your config/initializers/rails_admin.rb initializer:

RailsAdmin.config do |config|
  config.actions do
    ...
  end

  config.model MyModel do
    nestable_tree({
      position_field: :position,
      max_depth: 3
    })
  end
end

2. Nestable list:

To use this configuration, you need a position field

The nestable_list methods supports the following options:

  • position_field: (symbol) default :position
  • enable_callback: (boolean) default => false
  • scope: (symbol | proc) default => nil
  • live_update: (boolean | :only) default => true (:only is for live updating only)

In your config/initializers/rails_admin.rb initializer:

RailsAdmin.config do |config|
  config.actions do
    ...
  end

  config.model MyModel do
    nestable_list true
  end
end

Authorization with CanCan

Sample ability:

class Ability
  include CanCan::Ability

  def initialize(user)
    user ||= User.new

    if user.admin?
      can :access, :rails_admin
      can :dashboard

      if user.role? :superadmin
        can :manage, :all
      end

      if user.role? :editor
        can :edit, :all
        can :nestable, :all
      end
    end
  end
end

Screenshot

Nestable view

Contributing

Submitting a Pull Request:

  1. Fork the repository.
  2. Create a topic branch.
  3. Implement your feature or bug fix.
  4. Add, commit, and push your changes.
  5. Submit a pull request.

Thanks

License

This project rocks and uses MIT-LICENSE.

Copyright 2015 Andrea Dal Ponte

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

rails_admin_nestable's People

Contributors

benhutton avatar dalpo avatar dieunb avatar franckdelage avatar gokure avatar ideadapt avatar infernalmaster avatar javifr avatar jesson avatar juanfram avatar neilang avatar nicovak avatar rob-mcgrail avatar subrova avatar sudosu avatar tagliala avatar thiagoa avatar vened avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

rails_admin_nestable's Issues

Unable to get rails_admin_nestable working

I created my rails app with latest rails_admin_nestable, rails_admin, ancestry. I also added the needed configuration in config/initializers/rails_admin.rb. I am trying to get the nestable_tree in UI, for that I referred a helper method 'nested_tree_nodes' which throws a error

'undefined method `with' for nil:NilClass'

Is any configuration missing in doc? Or am I doing wrong anywhere?
How to resolve this?

ActionView::Template::Error on Rails 6

I've got a Rails 6 app installed from the box, setup the gem and getting an error on the tree saving.

SEE THE FIX IN THE COMMENT BELOW.

Environment

  • Rails: 6.0.2.2
  • Ruby: 2.7.1

Gem versions

  • ancestry (3.0.7)
  • rails_admin (2.0.2)
  • rails_admin_nestable (0.3.2)

Error

ActionView::Template::Error (undefined method `map' for nil:NilClass):
     8:   .form-group
     9:     #tree_nodes.dd{ data: { update_path: nestable_path(model_name: @abstract_model), max_depth: tree_max_depth } }
    10:       %ol.dd-list
    11:         = nested_tree_nodes @tree_nodes
    12:   - if @options[:live_update] != :only
    13:     .form-group
    14:       %button.btn.btn-primary{ type: 'submit' }= t('admin.actions.nestable.update')

rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:4:in `nested_tree_nodes'
rails_admin_nestable (0.3.2) app/views/rails_admin/main/nestable.html.haml:11

Framework Trace

actionview (6.0.2.2) lib/action_view/base.rb:274:in `_run'
actionview (6.0.2.2) lib/action_view/template.rb:185:in `block in render'
activesupport (6.0.2.2) lib/active_support/notifications.rb:182:in `instrument'
actionview (6.0.2.2) lib/action_view/template.rb:386:in `instrument_render_template'
actionview (6.0.2.2) lib/action_view/template.rb:183:in `render'
actionview (6.0.2.2) lib/action_view/renderer/template_renderer.rb:59:in `block (2 levels) in render_template'
actionview (6.0.2.2) lib/action_view/renderer/abstract_renderer.rb:89:in `block in instrument'
activesupport (6.0.2.2) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.2) lib/active_support/notifications.rb:180:in `instrument'
actionview (6.0.2.2) lib/action_view/renderer/abstract_renderer.rb:88:in `instrument'
actionview (6.0.2.2) lib/action_view/renderer/template_renderer.rb:58:in `block in render_template'
actionview (6.0.2.2) lib/action_view/renderer/template_renderer.rb:66:in `render_with_layout'
actionview (6.0.2.2) lib/action_view/renderer/template_renderer.rb:57:in `render_template'
actionview (6.0.2.2) lib/action_view/renderer/template_renderer.rb:13:in `render'
actionview (6.0.2.2) lib/action_view/renderer/renderer.rb:61:in `render_template_to_object'
actionview (6.0.2.2) lib/action_view/renderer/renderer.rb:29:in `render_to_object'
actionview (6.0.2.2) lib/action_view/rendering.rb:118:in `block in _render_template'
actionview (6.0.2.2) lib/action_view/base.rb:304:in `in_rendering_context'
actionview (6.0.2.2) lib/action_view/rendering.rb:117:in `_render_template'
actionpack (6.0.2.2) lib/action_controller/metal/streaming.rb:219:in `_render_template'
actionview (6.0.2.2) lib/action_view/rendering.rb:103:in `render_to_body'
actionpack (6.0.2.2) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (6.0.2.2) lib/action_controller/metal/renderers.rb:142:in `render_to_body'
actionpack (6.0.2.2) lib/abstract_controller/rendering.rb:25:in `render'
actionpack (6.0.2.2) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (6.0.2.2) lib/active_support/core_ext/benchmark.rb:14:in `block in ms'
/home/webadmin/.rvm/rubies/ruby-2.7.1/lib/ruby/2.7.0/benchmark.rb:308:in `realtime'
activesupport (6.0.2.2) lib/active_support/core_ext/benchmark.rb:14:in `ms'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:85:in `cleanup_view_runtime'
activerecord (6.0.2.2) lib/active_record/railties/controller_runtime.rb:34:in `cleanup_view_runtime'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:43:in `render'
remotipart (1.4.4) lib/remotipart/render_overrides.rb:23:in `render'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/nestable.rb:66:in `block (2 levels) in <class:Nestable>'
rails_admin (2.0.2) app/controllers/rails_admin/main_controller.rb:22:in `instance_eval'
rails_admin (2.0.2) app/controllers/rails_admin/main_controller.rb:22:in `nestable'
actionpack (6.0.2.2) lib/action_controller/metal/basic_implicit_render.rb:6:in `send_action'
actionpack (6.0.2.2) lib/abstract_controller/base.rb:196:in `process_action'
actionpack (6.0.2.2) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (6.0.2.2) lib/abstract_controller/callbacks.rb:42:in `block in process_action'
activesupport (6.0.2.2) lib/active_support/callbacks.rb:135:in `run_callbacks'
actionpack (6.0.2.2) lib/abstract_controller/callbacks.rb:41:in `process_action'
actionpack (6.0.2.2) lib/action_controller/metal/rescue.rb:22:in `process_action'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:33:in `block in process_action'
activesupport (6.0.2.2) lib/active_support/notifications.rb:180:in `block in instrument'
activesupport (6.0.2.2) lib/active_support/notifications/instrumenter.rb:24:in `instrument'
activesupport (6.0.2.2) lib/active_support/notifications.rb:180:in `instrument'
actionpack (6.0.2.2) lib/action_controller/metal/instrumentation.rb:32:in `process_action'
actionpack (6.0.2.2) lib/action_controller/metal/params_wrapper.rb:245:in `process_action'
activerecord (6.0.2.2) lib/active_record/railties/controller_runtime.rb:27:in `process_action'
actionpack (6.0.2.2) lib/abstract_controller/base.rb:136:in `process'
actionview (6.0.2.2) lib/action_view/rendering.rb:39:in `process'
actionpack (6.0.2.2) lib/action_controller/metal.rb:191:in `dispatch'
actionpack (6.0.2.2) lib/action_controller/metal.rb:252:in `dispatch'
actionpack (6.0.2.2) lib/action_dispatch/routing/route_set.rb:51:in `dispatch'
actionpack (6.0.2.2) lib/action_dispatch/routing/route_set.rb:33:in `serve'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.2) lib/action_dispatch/routing/route_set.rb:837:in `call'
railties (6.0.2.2) lib/rails/engine.rb:526:in `call'
railties (6.0.2.2) lib/rails/railtie.rb:190:in `public_send'
railties (6.0.2.2) lib/rails/railtie.rb:190:in `method_missing'
actionpack (6.0.2.2) lib/action_dispatch/routing/mapper.rb:19:in `block in <class:Constraints>'
actionpack (6.0.2.2) lib/action_dispatch/routing/mapper.rb:48:in `serve'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:49:in `block in serve'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:32:in `each'
actionpack (6.0.2.2) lib/action_dispatch/journey/router.rb:32:in `serve'
actionpack (6.0.2.2) lib/action_dispatch/routing/route_set.rb:837:in `call'
rack-pjax (1.1.0) lib/rack/pjax.rb:12:in `call'
remotipart (1.4.4) lib/remotipart/middleware.rb:32:in `call'
rack (2.2.2) lib/rack/tempfile_reaper.rb:15:in `call'
rack (2.2.2) lib/rack/etag.rb:27:in `call'
rack (2.2.2) lib/rack/conditional_get.rb:40:in `call'
rack (2.2.2) lib/rack/head.rb:12:in `call'
actionpack (6.0.2.2) lib/action_dispatch/http/content_security_policy.rb:18:in `call'
rack (2.2.2) lib/rack/session/abstract/id.rb:266:in `context'
rack (2.2.2) lib/rack/session/abstract/id.rb:260:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/cookies.rb:648:in `call'
activerecord (6.0.2.2) lib/active_record/migration.rb:567:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/callbacks.rb:27:in `block in call'
activesupport (6.0.2.2) lib/active_support/callbacks.rb:101:in `run_callbacks'
actionpack (6.0.2.2) lib/action_dispatch/middleware/callbacks.rb:26:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/actionable_exceptions.rb:17:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/debug_exceptions.rb:32:in `call'
web-console (4.0.1) lib/web_console/middleware.rb:132:in `call_app'
web-console (4.0.1) lib/web_console/middleware.rb:19:in `block in call'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `catch'
web-console (4.0.1) lib/web_console/middleware.rb:17:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/show_exceptions.rb:33:in `call'
railties (6.0.2.2) lib/rails/rack/logger.rb:38:in `call_app'
railties (6.0.2.2) lib/rails/rack/logger.rb:26:in `block in call'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:80:in `block in tagged'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:28:in `tagged'
activesupport (6.0.2.2) lib/active_support/tagged_logging.rb:80:in `tagged'
railties (6.0.2.2) lib/rails/rack/logger.rb:26:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/remote_ip.rb:81:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/request_id.rb:27:in `call'
rack (2.2.2) lib/rack/method_override.rb:24:in `call'
rack (2.2.2) lib/rack/runtime.rb:22:in `call'
activesupport (6.0.2.2) lib/active_support/cache/strategy/local_cache_middleware.rb:29:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/executor.rb:14:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/static.rb:126:in `call'
rack (2.2.2) lib/rack/sendfile.rb:110:in `call'
actionpack (6.0.2.2) lib/action_dispatch/middleware/host_authorization.rb:83:in `call'
webpacker (4.2.2) lib/webpacker/dev_server_proxy.rb:23:in `perform_request'
rack-proxy (0.6.5) lib/rack/proxy.rb:57:in `call'
railties (6.0.2.2) lib/rails/engine.rb:526:in `call'
puma (4.3.3) lib/puma/configuration.rb:228:in `call'
puma (4.3.3) lib/puma/server.rb:682:in `handle_request'
puma (4.3.3) lib/puma/server.rb:472:in `process_client'
puma (4.3.3) lib/puma/server.rb:328:in `block in run'
puma (4.3.3) lib/puma/thread_pool.rb:134:in `block in spawn_thread'

Compatible with Rails 7.0

Hello. My problem is not support version. I need upgrade Rails 6 to 7. But gem is not work from Rails 7 :-(
Plz, if your are can update this gem - I will be immensely grateful.

License missing from gemspec

RubyGems.org doesn't report a license for your gem. This is because it is not specified in the gemspec of your last release.

via e.g.

spec.license = 'MIT'
# or
spec.licenses = ['MIT', 'GPL-2']

Including a license in your gemspec is an easy way for rubygems.org and other tools to check how your gem is licensed. As you can imagine, scanning your repository for a LICENSE file or parsing the README, and then attempting to identify the license or licenses is much more difficult and more error prone. So, even for projects that already specify a license, including a license in your gemspec is a good practice. See, for example, how rubygems.org uses the gemspec to display the rails gem license.

There is even a License Finder gem to help companies/individuals ensure all gems they use meet their licensing needs. This tool depends on license information being available in the gemspec. This is an important enough issue that even Bundler now generates gems with a default 'MIT' license.

I hope you'll consider specifying a license in your gemspec. If not, please just close the issue with a nice message. In either case, I'll follow up. Thanks for your time!

Appendix:

If you need help choosing a license (sorry, I haven't checked your readme or looked for a license file), GitHub has created a license picker tool. Code without a license specified defaults to 'All rights reserved'-- denying others all rights to use of the code.
Here's a list of the license names I've found and their frequencies

p.s. In case you're wondering how I found you and why I made this issue, it's because I'm collecting stats on gems (I was originally looking for download data) and decided to collect license metadata,too, and make issues for gemspecs not specifying a license as a public service :). See the previous link or my blog post about this project for more information.

Problems getting started

Firstly, this looks like exactly what I need. Thanks!

I'm transitioning over from my old solution, which used acts_as_tree and was very similar.
http://ifailedtheturingtest.herokuapp.com/rails_admin/comment/985/tree ([email protected], password)
I really like your project more though . It looks much nicer and the drag and drop to rearrange is a big plus.

However, I can't get rails_admin_nestable working correctly. Configuring as nestable_list returns just an un-nested list of all comments. Configuring as nestable_tree is a little better but I still can't drag and drop the rows to re-order them. Or at least that what seemed I should do, judging by the screenshot in the README.

Rather than load all my files here, I'll just point to my project https://github.com/adamwong246/StEnki

Lastly, is there any plans to support pagination? Rails_admin_nestable loads up everything and I'd like to be able to examine subsets of tree to reduce load.

thanks

Possible bug with position field in nestable_tree

I've got some strange behavior with nestable_tree:
it shows wrong structure. Specifically, it doesn't show first level children as children, but as root elements.
I've found out that it's likely because of arrange function from Ancestry.
It returns wrong hash if i use separate position_field.
However, ancestry field in table is correct and functions like ancestry_ids, children, etc - work as usual.

My guess is that possibly this line (from arrange function):
self.base_class.ordered_by_ancestry_and options.delete(:order)
doesn't work well with this field.

Model config:

    nestable_tree({
      position_field: :position,
      max_depth: 3
    })

CanCan filters that work on :index have no effect on :nestable

I am having this lib fail to respect CanCan attribute filters, like

cannot :nestable, Model
can :nestable, Model, thing_id: some_id

It appears to respect only the basic "can x", "cannot y", but not the attribute hash.

These same filters work fine for INDEX action, eg,

cannot :index, Model
can :index, Model, thing_id: some_id

Correctly restricts the same model in the index action, but shows all instances in the nestable action.

couldn't find file 'jquery.nestable.js'

couldn't find file 'jquery.nestable.js'
(in /home/sergey/.rvm/gems/ruby-1.9.3-p194@global/gems/rails_admin_nestable-0.0.3/app/assets/javascripts/rails_admin/rails_admin_nestable.js.coffee:1)

NoMethodError in RailsAdmin::Main#nestable

I'm trying to drag/sort items with a nestable_tree organized with Ancestry and encountering the error below:

Environment

Rails: 5.1.6
Ruby: 2.4.1

config:

rails_admin do
  nestable_tree({
    position_field: :position,
    max_depth: 3
  })
end

Model has t.integer :position and t.string :ancestry, with ancestry gem installed.

Error

NoMethodError in RailsAdmin::Main#nestable

Showing /.rvm/gems/ruby-2.4.1/gems/rails_admin_nestable-0.3.2/app/views/rails_admin/main/nestable.html.haml where line #11 raised:
undefined method `map' for nil:NilClass
Framework Trace
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:4:in `nested_tree_nodes'
rails_admin_nestable (0.3.2) app/views/rails_admin/main/nestable.html.haml:11:in `___sers__rvm_gems_ruby_______gems_rails_admin_nestable_______app_views_rails_admin_main_nestable_html_haml___1225494274636441108_70308752925720'
actionview (5.1.6) lib/action_view/template.rb:157:in `block in render'
activesupport (5.1.6) lib/active_support/notifications.rb:168:in `instrument'
actionview (5.1.6) lib/action_view/template.rb:352:in `instrument_render_template'
actionview (5.1.6) lib/action_view/template.rb:155:in `render'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:52:in `block (2 levels) in render_template'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:42:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionview (5.1.6) lib/action_view/renderer/abstract_renderer.rb:41:in `instrument'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:51:in `block in render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:59:in `render_with_layout'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:50:in `render_template'
actionview (5.1.6) lib/action_view/renderer/template_renderer.rb:14:in `render'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:42:in `render_template'
actionview (5.1.6) lib/action_view/renderer/renderer.rb:23:in `render'
actionview (5.1.6) lib/action_view/rendering.rb:103:in `_render_template'
actionpack (5.1.6) lib/action_controller/metal/streaming.rb:217:in `_render_template'
actionview (5.1.6) lib/action_view/rendering.rb:83:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:52:in `render_to_body'
actionpack (5.1.6) lib/action_controller/metal/renderers.rb:141:in `render_to_body'
actionpack (5.1.6) lib/abstract_controller/rendering.rb:24:in `render'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:36:in `render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block (2 levels) in render'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `block in ms'
/.rvm/rubies/ruby-2.4.1/lib/ruby/2.4.0/benchmark.rb:308:in `realtime'
activesupport (5.1.6) lib/active_support/core_ext/benchmark.rb:12:in `ms'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:44:in `block in render'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:87:in `cleanup_view_runtime'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:29:in `cleanup_view_runtime'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:43:in `render'
remotipart (1.3.1) lib/remotipart/render_overrides.rb:16:in `render_with_remotipart'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/nestable.rb:66:in `block (2 levels) in <class:Nestable>'
rails_admin (1.3.0) app/controllers/rails_admin/main_controller.rb:22:in `instance_eval'
rails_admin (1.3.0) app/controllers/rails_admin/main_controller.rb:22:in `nestable'
actionpack (5.1.6) lib/action_controller/metal/basic_implicit_render.rb:4:in `send_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:186:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rendering.rb:30:in `process_action'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:20:in `block in process_action'
activesupport (5.1.6) lib/active_support/callbacks.rb:131:in `run_callbacks'
actionpack (5.1.6) lib/abstract_controller/callbacks.rb:19:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/rescue.rb:20:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:32:in `block in process_action'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `block in instrument'
activesupport (5.1.6) lib/active_support/notifications/instrumenter.rb:21:in `instrument'
activesupport (5.1.6) lib/active_support/notifications.rb:166:in `instrument'
actionpack (5.1.6) lib/action_controller/metal/instrumentation.rb:30:in `process_action'
actionpack (5.1.6) lib/action_controller/metal/params_wrapper.rb:252:in `process_action'
activerecord (5.1.6) lib/active_record/railties/controller_runtime.rb:22:in `process_action'
actionpack (5.1.6) lib/abstract_controller/base.rb:124:in `process'
actionview (5.1.6) lib/action_view/rendering.rb:30:in `process'
actionpack (5.1.6) lib/action_controller/metal.rb:189:in `dispatch'
actionpack (5.1.6) lib/action_controller/metal.rb:253:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:49:in `dispatch'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:31:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
railties (5.1.6) lib/rails/railtie.rb:185:in `public_send'
railties (5.1.6) lib/rails/railtie.rb:185:in `method_missing'
actionpack (5.1.6) lib/action_dispatch/routing/mapper.rb:17:in `block in <class:Constraints>'
actionpack (5.1.6) lib/action_dispatch/routing/mapper.rb:46:in `serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:50:in `block in serve'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `each'
actionpack (5.1.6) lib/action_dispatch/journey/router.rb:33:in `serve'
actionpack (5.1.6) lib/action_dispatch/routing/route_set.rb:844:in `call'
rack-pjax (1.0.0) lib/rack/pjax.rb:12:in `call'
remotipart (1.3.1) lib/remotipart/middleware.rb:32:in `call'
warden (1.2.7) lib/warden/manager.rb:36:in `block in call'
warden (1.2.7) lib/warden/manager.rb:35:in `catch'
warden (1.2.7) lib/warden/manager.rb:35:in `call'
rack (2.0.4) lib/rack/etag.rb:25:in `call'
rack (2.0.4) lib/rack/conditional_get.rb:38:in `call'
rack (2.0.4) lib/rack/head.rb:12:in `call'
rack (2.0.4) lib/rack/session/abstract/id.rb:232:in `context'
rack (2.0.4) lib/rack/session/abstract/id.rb:226:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/cookies.rb:613:in `call'
activerecord (5.1.6) lib/active_record/migration.rb:556:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:26:in `block in call'
activesupport (5.1.6) lib/active_support/callbacks.rb:97:in `run_callbacks'
actionpack (5.1.6) lib/action_dispatch/middleware/callbacks.rb:24:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/debug_exceptions.rb:59:in `call'
web-console (3.5.1) lib/web_console/middleware.rb:135:in `call_app'
web-console (3.5.1) lib/web_console/middleware.rb:28:in `block in call'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `catch'
web-console (3.5.1) lib/web_console/middleware.rb:18:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/show_exceptions.rb:31:in `call'
railties (5.1.6) lib/rails/rack/logger.rb:36:in `call_app'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `block in call'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `block in tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:26:in `tagged'
activesupport (5.1.6) lib/active_support/tagged_logging.rb:69:in `tagged'
railties (5.1.6) lib/rails/rack/logger.rb:24:in `call'
sprockets-rails (3.2.1) lib/sprockets/rails/quiet_assets.rb:13:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/remote_ip.rb:79:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/request_id.rb:25:in `call'
rack (2.0.4) lib/rack/method_override.rb:22:in `call'
rack (2.0.4) lib/rack/runtime.rb:22:in `call'
activesupport (5.1.6) lib/active_support/cache/strategy/local_cache_middleware.rb:27:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/executor.rb:12:in `call'
actionpack (5.1.6) lib/action_dispatch/middleware/static.rb:125:in `call'
rack (2.0.4) lib/rack/sendfile.rb:111:in `call'
railties (5.1.6) lib/rails/engine.rb:522:in `call'
puma (3.11.3) lib/puma/configuration.rb:225:in `call'
puma (3.11.3) lib/puma/server.rb:624:in `handle_request'
puma (3.11.3) lib/puma/server.rb:438:in `process_client'
puma (3.11.3) lib/puma/server.rb:302:in `block in run'
puma (3.11.3) lib/puma/thread_pool.rb:120:in `block in spawn_thread'

Filter Tree View Rows

I want to filter my tree view rows as I did in my listing. is that possible? How?

Tree with multiple root nodes doesn't maintain order

I'm struggling with an issue which is a little complex to explain.

If I have a list of nodes like so:

-- page 1
-- page 2
-- page 3

If I nest a node under any non-first root node:

-- page 1
-- page 2
    -- page 3

The order will reset when the list is refreshed:

-- page 1
-- page 2
-- page 3

However, if an item is nested under the first root node, the order persists across page refreshes:

-- page 1
    -- page 2
-- page 3

I'm using the ancestry 1.3.0 gem.

N.B. Calling model.arrange reveals the incorrect order being returned. However, calling model.roots then looping through the children produces the correctly set order.

Use it without RailsAdmin?

Hey, is it possible to use this awesome plugin without RailsAdmin? I would love to put the tree-view with the possibility to edit everything directly into a normal user page, reachable with devise.. Any ideas how to do it? :)

Nestable List broken

Hi, when trying to access the nestable list for a correctly configured model, I get an error about the missing method modelorder on AbstractModel class.

This is a regression from the previous version

Typo in docs

Hi,
there is a typo in your readme:

nestable_tree { position_field: :position, max_depth: 3 }

instead of

nestable_tree({ position_field: :position, max_depth: 3 })

Thank you for this gem, is very useful!

Gets stuck in loop

Hey!

Using the following:

gem 'ancestry'
gem 'rails_admin', '~> 1.1.1'
gem 'rails_admin_nestable', '~> 0.3.2'

After loading and making changes, I'm getting stuck in a loop of the following:

actionview (5.0.1) lib/action_view/helpers/capture_helper.rb:39:in `block in capture'
actionview (5.0.1) lib/action_view/helpers/capture_helper.rb:203:in `with_output_buffer'
haml (4.0.7) lib/haml/helpers/action_view_xss_mods.rb:5:in `with_output_buffer_with_haml_xss'
actionview (5.0.1) lib/action_view/helpers/capture_helper.rb:39:in `capture'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:52:in `capture_with_haml'
actionview (5.0.1) lib/action_view/helpers/tag_helper.rb:107:in `content_tag'
haml (4.0.7) lib/haml/helpers/action_view_mods.rb:69:in `content_tag_with_haml'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:7:in `block in nested_tree_nodes'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:4:in `each'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:4:in `map'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:4:in `nested_tree_nodes'
rails_admin_nestable (0.3.2) lib/rails_admin_nestable/helper.rb:15:in `block (2 levels) in nested_tree_nodes'

Config looks like:

...
config.model Page do
    nestable_tree({
      position_field: :ancestry,
      max_depth: 3
    })
  end

and


class Page < ApplicationRecord
    has_ancestry 
    ...
end

The values that end up in the ancestry col are just integers ( ancestry: "2" ) whereas my understanding is they should look more like paths ( ancestry: "1/2" ).

"undefined method `options' for nil:NilClass" when using nestable_list

Trying to use nestable_list for a model that has a :position fieldโ€”installed gem, added nestable to actions in rails_admin.rb:

  config.actions do
    nestable
  end

and in my models/perk.rb:

  rails_admin do
    ...
    nestable_list true
    ...
  end

Using rails_admin 0.6.0 and Rails 4.0.0.

Any help much appreciated. I cloned the gem locally and wasn't able to find where the issue was.

Framework trace:

vendor/gems/rails_admin_nestable/lib/rails_admin_nestable/helper.rb:32:in tree_max_depth' vendor/gems/rails_admin_nestable/app/views/rails_admin/main/nestable.html.haml:6:in_vendor_gems_rails_admin_nestable_app_views_rails_admin_main_nestable_html_haml___2739447881632247793_70350316666780'
actionpack (4.0.0) lib/action_view/template.rb:143:in block in render' activesupport (4.0.0) lib/active_support/notifications.rb:161:ininstrument'
actionpack (4.0.0) lib/action_view/template.rb:141:in render' actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:49:inblock (2 levels) in render_template'
actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:38:in block in instrument' activesupport (4.0.0) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.0.0) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.0.0) lib/action_view/renderer/abstract_renderer.rb:38:in instrument' actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:48:inblock in render_template'
actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:56:in render_with_layout' actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:47:inrender_template'
actionpack (4.0.0) lib/action_view/renderer/template_renderer.rb:17:in render' actionpack (4.0.0) lib/action_view/renderer/renderer.rb:42:inrender_template'
actionpack (4.0.0) lib/action_view/renderer/renderer.rb:23:in render' actionpack (4.0.0) lib/abstract_controller/rendering.rb:127:in_render_template'
actionpack (4.0.0) lib/action_controller/metal/streaming.rb:219:in _render_template' actionpack (4.0.0) lib/abstract_controller/rendering.rb:120:inrender_to_body'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:33:in render_to_body' actionpack (4.0.0) lib/action_controller/metal/renderers.rb:26:inrender_to_body'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:97:in render' actionpack (4.0.0) lib/action_controller/metal/rendering.rb:16:inrender'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in block (2 levels) in render' activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:inblock in ms'
/Users/nate/.rbenv/versions/2.0.0-p247/lib/ruby/2.0.0/benchmark.rb:296:in realtime' activesupport (4.0.0) lib/active_support/core_ext/benchmark.rb:12:inms'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:41:in block in render' actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:84:incleanup_view_runtime'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:25:in cleanup_view_runtime' actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:40:inrender'
remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:in render_with_remotipart' actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:10:indefault_render'
actionpack (4.0.0) lib/action_controller/metal/implicit_render.rb:4:in send_action' actionpack (4.0.0) lib/abstract_controller/base.rb:189:inprocess_action'
actionpack (4.0.0) lib/action_controller/metal/rendering.rb:10:in process_action' actionpack (4.0.0) lib/abstract_controller/callbacks.rb:18:inblock in process_action'
activesupport (4.0.0) lib/active_support/callbacks.rb:463:in _run__490290861130289315__process_action__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.0) lib/abstract_controller/callbacks.rb:17:in process_action' actionpack (4.0.0) lib/action_controller/metal/rescue.rb:29:inprocess_action'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:31:in block in process_action' activesupport (4.0.0) lib/active_support/notifications.rb:159:inblock in instrument'
activesupport (4.0.0) lib/active_support/notifications/instrumenter.rb:20:in instrument' activesupport (4.0.0) lib/active_support/notifications.rb:159:ininstrument'
actionpack (4.0.0) lib/action_controller/metal/instrumentation.rb:30:in process_action' actionpack (4.0.0) lib/action_controller/metal/params_wrapper.rb:245:inprocess_action'
activerecord (4.0.0) lib/active_record/railties/controller_runtime.rb:18:in process_action' actionpack (4.0.0) lib/abstract_controller/base.rb:136:inprocess'
actionpack (4.0.0) lib/abstract_controller/rendering.rb:44:in process' actionpack (4.0.0) lib/action_controller/metal.rb:195:indispatch'
actionpack (4.0.0) lib/action_controller/metal/rack_delegation.rb:13:in dispatch' actionpack (4.0.0) lib/action_controller/metal.rb:231:inblock in action'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:in call' actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:80:indispatch'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:48:in call' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:inblock in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:incall'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in call' railties (4.0.0) lib/rails/engine.rb:511:incall'
railties (4.0.0) lib/rails/railtie/configurable.rb:30:in method_missing' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:71:inblock in call'
actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:in each' actionpack (4.0.0) lib/action_dispatch/journey/router.rb:59:incall'
actionpack (4.0.0) lib/action_dispatch/routing/route_set.rb:655:in call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:incall!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:incall!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in call' omniauth (1.1.4) lib/omniauth/strategy.rb:184:incall!'
omniauth (1.1.4) lib/omniauth/strategy.rb:164:in call' rack-raw-upload (1.1.1) lib/rack/raw_upload.rb:18:incall'
rack-pjax (0.7.0) lib/rack/pjax.rb:12:in call' rack-ssl-enforcer (0.2.6) lib/rack/ssl-enforcer.rb:51:incall'
warden (1.2.3) lib/warden/manager.rb:35:in block in call' warden (1.2.3) lib/warden/manager.rb:34:incatch'
warden (1.2.3) lib/warden/manager.rb:34:in call' rack (1.5.2) lib/rack/etag.rb:23:incall'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:incall'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in call' actionpack (4.0.0) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.0) lib/action_dispatch/middleware/cookies.rb:486:incall'
activerecord (4.0.0) lib/active_record/query_cache.rb:36:in call' activerecord (4.0.0) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
activerecord (4.0.0) lib/active_record/migration.rb:369:in call' actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.0.0) lib/active_support/callbacks.rb:373:in _run__1102643539860257370__call__callbacks' activesupport (4.0.0) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.0) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.0.0) lib/action_dispatch/middleware/reloader.rb:64:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.0) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.0) lib/rails/rack/logger.rb:38:incall_app'
railties (4.0.0) lib/rails/rack/logger.rb:21:in block in call' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:inblock in tagged'
activesupport (4.0.0) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.0) lib/active_support/tagged_logging.rb:67:intagged'
railties (4.0.0) lib/rails/rack/logger.rb:21:in call' actionpack (4.0.0) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.0.0) lib/active_support/cache/strategy/local_cache.rb:83:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
actionpack (4.0.0) lib/action_dispatch/middleware/static.rb:64:in call' railties (4.0.0) lib/rails/engine.rb:511:incall'
railties (4.0.0) lib/rails/application.rb:97:in call' /Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:145:inhandle'
/Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:99:in rescue in block (2 levels) in start' /Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:96:inblock (2 levels) in start'
/Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:86:in each' /Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:86:inblock in start'
/Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:66:in loop' /Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:66:instart'
/Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/lib/nack/server.rb:13:in run' /Users/nate/Library/Application Support/Pow/Versions/0.4.1/node_modules/nack/bin/nack_worker:4:in

'

How to configure without rails_admin gem

I have gone through your gem its simply superb. I am new to rails, trying to integrating this into my project with out using rails_admin gem but I could't able to do it.

Can you please help.....

Thanks

Use in app view not admin (not an issue)

I have this gem working. It's great!

But, is there anyway to use just the display sorting in a regular Rails view instead of just Admin?

That would be awesome.

nestable list not nestable

Steps to reproduce:

  1. Add nestable_list configuration to initializers/rails_admin.rb:

    config.model ModelName do
      nestable_list true
    end
  2. Add migration:

    class AddPositionToModelName < ActiveRecord::Migration
      def change
        add_column :model_name, :position, :string, index: true
      end
    end
  3. Create 3 ModelName items in Rails Admin

  4. Access Sorting tab

  5. Try to drag one item into the other

What happens: items can not be nested.

What should happen: if the list is nestable, it should be possible to drag one item into another.

Safari 9.1.2 (11601.7.7)
rails 4.2.6
ruby 2.3.1
rails_admin eefa8ac (latest master)
rails_admin_nestable 0.3.2

Sorting a tree

Hi,

Is there a way to sort a tree? The drag and drop is working but do not save anything, after a refresh everything comes back to the initial order, only the hiearchy remains.

My use case is the categories in a website, I want to be able to modify the menu dynamically (hiearchy and order) in the administration board.

It could also be an ancestry issue!

wrong number of arguments (1 for 3) when update

Hey,

I trying to use nestable and when i update i get a alert message "wrong number of arguments (1 for 3)"

Version :

  • Rails 4.0.2
  • Ruby 2.1.1p76
  • rails_admin (0.6.1 025de0c)
  • rails_admin_nestable (0.1.7 fc4d10a)

In my model :

   rails_admin do 
       nestable_list true
       .....
   end

In rails_admin.rb :

   config.actions do
       nestable
       .....
   end

And in the migration :

   create_table :features_categories do |t|
       t.integer :position, default: 0
       ....
   end

Error from rails console :

Started POST "/admin/partner/nestable" for 127.0.0.1 at 2014-03-13 14:13:32 +0100
Processing by RailsAdmin::MainController#nestable as */*
  Parameters: {"tree_nodes"=>{"0"=>{"id"=>"10"}, "1"=>{"id"=>"12"}, "2"=>{"id"=>"11"}, "3"=>{"id"=>"9"}, "4"=>{"id"=>"8"}, "5"=>{"id"=>"7"}, "6"=>{"id"=>"6"}, "7"=>{"id"=>"5"}, "8"=>{"id"=>"4"}, "9"=>{"id"=>"3"}, "10"=>{"id"=>"2"}, "11"=>{"id"=>"1"}}, "model_name"=>"partner"}
  User Load (0.8ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
   (0.3ms)  BEGIN
   (0.2ms)  ROLLBACK
  Rendered text template (0.1ms)
Completed 200 OK in 12ms (Views: 0.7ms | ActiveRecord: 1.3ms)

I don't understand because i have create a other project 1 month ago and every think work well with exactly the same configuration BUT the commit version is different.

  • rails_admin (0.6.0 2010c96)
  • rails_admin_nestable (0.1.7 9201861)

for exemple when i update the position in this project

Started POST "/admin/photo/nestable" for 127.0.0.1 at 2014-03-13 10:57:32 +0100
Processing by RailsAdmin::MainController#nestable as */*
  Parameters: {"tree_nodes"=>{"0"=>{"id"=>"2"}, "1"=>{"id"=>"4"}, "2"=>{"id"=>"5"}, "3"=>{"id"=>"6"}, "4"=>{"id"=>"7"}, "5"=>{"id"=>"8"}, "6"=>{"id"=>"9"}, "7"=>{"id"=>"10"}, "8"=>{"id"=>"11"}, "9"=>{"id"=>"12"}, "10"=>{"id"=>"13"}, "11"=>{"id"=>"14"}, "12"=>{"id"=>"15"}, "13"=>{"id"=>"16"}, "14"=>{"id"=>"17"}, "15"=>{"id"=>"3"}, "16"=>{"id"=>"19"}}, "model_name"=>"photo"}
  User Load (0.9ms)  SELECT "users".* FROM "users" WHERE "users"."id" = 1 ORDER BY "users"."id" ASC LIMIT 1
   (0.5ms)  BEGIN
  Photo Load (2.2ms)  SELECT "photos".* FROM "photos" WHERE "photos"."id" = $1 LIMIT 1  [["id", 2]]
  SQL (1.5ms)  UPDATE "photos" SET "position" = $1, "updated_at" = $2 WHERE "photos"."id" = 2  [["position", 1], ["updated_at", Thu, 13 Mar 2014 10:57:32 CET +01:00]]
  Photo Load (0.7ms)  SELECT "photos".* FROM "photos" WHERE "photos"."id" = $1 LIMIT 1  [["id", 4]]
  SQL (1.5ms)  UPDATE "photos" SET "position" = $1, "updated_at" = $2 WHERE "photos"."id" = 4  [["position", 2], ["updated_at", Thu, 13 Mar 2014 10:57:32 CET +01:00]]

......

So i dont know what wrong if some one know :) thanks

Possibility to sort children of a parent (Has many association)

While taking a look at the source code and/or documentation it is unclear on how we could achieve the sortability of children of a parent class (something along of the lines of sorting Players for a given Team).

I would love to have that for a current project I am working on and if you could point me in the right direction I would gladly open up a PR.

My initial analysis takes me on the route to convert (or extend) the Sortable action to be able to use it within an association field which uses a different kind of configuration. If this is something we want included here I would more than gladly submit more information regarding my investigation.

How to display associated model's name in sorting menu

Currently I have "featured posts" list which has many associated "posts" in this list. In list menu rails_admin by default display name of the associated model but in sorting menu it display FeaturedPost#1, FeaturedPost#2 etc I want to display title of the post and position of the post in this sortable list
my current config

nestable do
      only ['FeaturedPost', 'FeaturedVideo']
    end
config.model 'FeaturedPost' do
    nestable_list true
    list do
      sort_by :position
      field :post
      field :position do
        sortable true
      end
    end
  end
config.model 'FeaturedVideo' do
    nestable_list true
    list do
      sort_by :position
      field :video
      field :position do
        sortable true
      end
    end
  end

What should I do? Please help!

Rails_admin_nestable is not working

Hi,

I am trying to use rails_admin_nestable with my new application (rails 4.0.0 , ruby 2.0.0) and it seems I have some configuration problems.
Would you please be so kind and help me to sort that out?

Here is the stack trace:

rails_admin_nestable (0.1.6) lib/rails_admin_nestable/helper.rb:12:in block (3 levels) in nested_tree_nodes' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:inblock in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in with_output_buffer' haml (4.0.4) lib/haml/helpers/action_view_xss_mods.rb:5:inwith_output_buffer_with_haml_xss'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in capture' haml (4.0.4) lib/haml/helpers/action_view_mods.rb:59:incapture_with_haml'
actionpack (4.0.2) lib/action_view/helpers/tag_helper.rb:94:in content_tag' haml (4.0.4) lib/haml/helpers/action_view_mods.rb:76:incontent_tag_with_haml'
rails_admin_nestable (0.1.6) lib/rails_admin_nestable/helper.rb:11:in block (2 levels) in nested_tree_nodes' actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:inblock in capture'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:200:in with_output_buffer' haml (4.0.4) lib/haml/helpers/action_view_xss_mods.rb:5:inwith_output_buffer_with_haml_xss'
actionpack (4.0.2) lib/action_view/helpers/capture_helper.rb:38:in capture' haml (4.0.4) lib/haml/helpers/action_view_mods.rb:59:incapture_with_haml'
actionpack (4.0.2) lib/action_view/helpers/tag_helper.rb:94:in content_tag' haml (4.0.4) lib/haml/helpers/action_view_mods.rb:76:incontent_tag_with_haml'
rails_admin_nestable (0.1.6) lib/rails_admin_nestable/helper.rb:8:in block in nested_tree_nodes' activerecord (4.0.2) lib/active_record/relation/delegation.rb:13:inmap'
activerecord (4.0.2) lib/active_record/relation/delegation.rb:13:in map' rails_admin_nestable (0.1.6) lib/rails_admin_nestable/helper.rb:5:innested_tree_nodes'
app/views/backend/menus/index.html.haml:28:in _app_views_backend_menus_index_html_haml__369050666100363292_38333240' actionpack (4.0.2) lib/action_view/template.rb:143:inblock in render'
activesupport (4.0.2) lib/active_support/notifications.rb:161:in instrument' actionpack (4.0.2) lib/action_view/template.rb:141:inrender'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:49:in block (2 levels) in render_template' actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:inblock in instrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in instrument' actionpack (4.0.2) lib/action_view/renderer/abstract_renderer.rb:38:ininstrument'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:48:in block in render_template' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:56:inrender_with_layout'
actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:47:in render_template' actionpack (4.0.2) lib/action_view/renderer/template_renderer.rb:17:inrender'
actionpack (4.0.2) lib/action_view/renderer/renderer.rb:42:in render_template' actionpack (4.0.2) lib/action_view/renderer/renderer.rb:23:inrender'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:127:in _render_template' actionpack (4.0.2) lib/action_controller/metal/streaming.rb:219:in_render_template'
actionpack (4.0.2) lib/abstract_controller/rendering.rb:120:in render_to_body' actionpack (4.0.2) lib/action_controller/metal/rendering.rb:33:inrender_to_body'
actionpack (4.0.2) lib/action_controller/metal/renderers.rb:26:in render_to_body' actionpack (4.0.2) lib/abstract_controller/rendering.rb:97:inrender'
actionpack (4.0.2) lib/action_controller/metal/rendering.rb:16:in render' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:inblock (2 levels) in render'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in block in ms' /home/martyna/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/benchmark.rb:296:inrealtime'
activesupport (4.0.2) lib/active_support/core_ext/benchmark.rb:12:in ms' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:41:inblock in render'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:84:in cleanup_view_runtime' activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:25:incleanup_view_runtime'
actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:40:in render' remotipart (1.2.1) lib/remotipart/render_overrides.rb:14:inrender_with_remotipart'
actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:10:in default_render' actionpack (4.0.2) lib/action_controller/metal/implicit_render.rb:5:insend_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:189:in process_action' actionpack (4.0.2) lib/action_controller/metal/rendering.rb:10:inprocess_action'
actionpack (4.0.2) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (4.0.2) lib/active_support/callbacks.rb:433:in_run__1923124304919436065__process_action__callbacks'
activesupport (4.0.2) lib/active_support/callbacks.rb:80:in run_callbacks' actionpack (4.0.2) lib/abstract_controller/callbacks.rb:17:inprocess_action'
actionpack (4.0.2) lib/action_controller/metal/rescue.rb:29:in process_action' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:31:inblock in process_action'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in block in instrument' activesupport (4.0.2) lib/active_support/notifications/instrumenter.rb:20:ininstrument'
activesupport (4.0.2) lib/active_support/notifications.rb:159:in instrument' actionpack (4.0.2) lib/action_controller/metal/instrumentation.rb:30:inprocess_action'
actionpack (4.0.2) lib/action_controller/metal/params_wrapper.rb:245:in process_action' activerecord (4.0.2) lib/active_record/railties/controller_runtime.rb:18:inprocess_action'
actionpack (4.0.2) lib/abstract_controller/base.rb:136:in process' actionpack (4.0.2) lib/abstract_controller/rendering.rb:44:inprocess'
actionpack (4.0.2) lib/action_controller/metal.rb:195:in dispatch' actionpack (4.0.2) lib/action_controller/metal/rack_delegation.rb:13:indispatch'
actionpack (4.0.2) lib/action_controller/metal.rb:231:in block in action' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:incall'
actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:80:in dispatch' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:48:incall'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:71:in block in call' actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:ineach'
actionpack (4.0.2) lib/action_dispatch/journey/router.rb:59:in call' actionpack (4.0.2) lib/action_dispatch/routing/route_set.rb:680:incall'
rack-pjax (0.7.0) lib/rack/pjax.rb:12:in call' rack (1.5.2) lib/rack/etag.rb:23:incall'
rack (1.5.2) lib/rack/conditionalget.rb:25:in call' rack (1.5.2) lib/rack/head.rb:11:incall'
remotipart (1.2.1) lib/remotipart/middleware.rb:27:in call' actionpack (4.0.2) lib/action_dispatch/middleware/params_parser.rb:27:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/flash.rb:241:in call' rack (1.5.2) lib/rack/session/abstract/id.rb:225:incontext'
rack (1.5.2) lib/rack/session/abstract/id.rb:220:in call' actionpack (4.0.2) lib/action_dispatch/middleware/cookies.rb:486:incall'
activerecord (4.0.2) lib/active_record/query_cache.rb:36:in call' activerecord (4.0.2) lib/active_record/connection_adapters/abstract/connection_pool.rb:626:incall'
activerecord (4.0.2) lib/active_record/migration.rb:369:in call' actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:29:inblock in call'
activesupport (4.0.2) lib/active_support/callbacks.rb:373:in _run__3001122453673559635__call__callbacks' activesupport (4.0.2) lib/active_support/callbacks.rb:80:inrun_callbacks'
actionpack (4.0.2) lib/action_dispatch/middleware/callbacks.rb:27:in call' actionpack (4.0.2) lib/action_dispatch/middleware/reloader.rb:64:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/remote_ip.rb:76:in call' actionpack (4.0.2) lib/action_dispatch/middleware/debug_exceptions.rb:17:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/show_exceptions.rb:30:in call' railties (4.0.2) lib/rails/rack/logger.rb:38:incall_app'
railties (4.0.2) lib/rails/rack/logger.rb:20:in block in call' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:inblock in tagged'
activesupport (4.0.2) lib/active_support/tagged_logging.rb:25:in tagged' activesupport (4.0.2) lib/active_support/tagged_logging.rb:67:intagged'
railties (4.0.2) lib/rails/rack/logger.rb:20:in call' actionpack (4.0.2) lib/action_dispatch/middleware/request_id.rb:21:incall'
rack (1.5.2) lib/rack/methodoverride.rb:21:in call' rack (1.5.2) lib/rack/runtime.rb:17:incall'
activesupport (4.0.2) lib/active_support/cache/strategy/local_cache.rb:83:in call' rack (1.5.2) lib/rack/lock.rb:17:incall'
actionpack (4.0.2) lib/action_dispatch/middleware/static.rb:64:in call' rack (1.5.2) lib/rack/sendfile.rb:112:incall'
railties (4.0.2) lib/rails/engine.rb:511:in call' railties (4.0.2) lib/rails/application.rb:97:incall'
rack (1.5.2) lib/rack/lock.rb:17:in call' rack (1.5.2) lib/rack/content_length.rb:14:incall'
rack (1.5.2) lib/rack/handler/webrick.rb:60:in service' /home/martyna/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:138:inservice'
/home/martyna/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/httpserver.rb:94:in run' /home/martyna/.rvm/rubies/ruby-2.0.0-p353/lib/ruby/2.0.0/webrick/server.rb:295:inblock in start_thread'

scope does not work as expected

Hello

I can not get scope to work as described in readme.
I use nestable_list and all the other configuration params work, but not scope. Could someone explain what i did wrong?

My rails_admin configuration file

 nestable_list({
  scope: :active,
  live_update: false
 })

Scopes are defined in my class as:

  scope :active, -> {where(status: "active")}
  scope :inactive, -> {where(status: "inactive")}
  scope :draft, -> {where(status: "draft")}
  scope :deleted, -> {where(status: "deleted")}

I have also tried using Proc.new to define my condition, but with no success.

Using default_scope as "active" it kinda works, but it doesn't play well with rails_admin edit option, because I can not edit articles that are not active.

Screenshot

How about a screenshot to let people see its functionality without fully installing it?

nestable_tree true is required

Hi guys,

I have been struggling to make my tree work and I think that there is something missing in the README of the project!

I think that you forgot to mention that nestable_tree true is mandatory in the rails_admin.rb in order to have a fully functional drag and drop tree.

The full snippet for a tree would therefore be :

RailsAdmin.config do |config|
  config.actions do
    ...
  end

  config.model MyModel do
    nestable_tree({
      position_field: :position,
      max_depth: 3
    })

  nestable_tree true
  end
end

Whithout this line my tree was just acting weird, the hiearchy was not saved and nothing was really working as it should have. It would be nice to add it so someone else doesn't struggle like me :-).

gets too slow for nodes > 10000

My ancestry tree contains more than 10000 nodes.

Is there any way to display only a part of the subtree say suppose all the children under a particular node, also with an option to add a new node to this subtree by search for its name in the entire tree or maybe add a new node and add it to this subtree as a child?

Dragging isn't working for me

I'm using Ancestry for a table called locations. I can see the hierarchy in the Rails Admin Sort - but, I can't drag an entry to another spot.

This is my rails_admin.rb:

 # Add the nestable action for each model
  nestable do
    visible do
      %w(Location).include? bindings[:abstract_model].model_name
    end
  end
end

  config.model 'Location' do
    nestable_tree({
        position_field: :position,
        max_depth: 5
     })
  end  

Problem Getting Position field to generate value in Production

Hello,

First, let me say thank you for this gem! This is the second project I implemented it into in the last week.

I am using the nestable_list. I have everything working perfect on Localhost

however, whenever I try to run this in production on heroku using the PG shared database :dev plan, I'm getting an 500 error when I try to go to the "Sorting" tab in rails_admin.

The "position" field is not being assigned a value in production, but it is in development. And I have ran my migrations on the production db.

Have you experienced this issue before?

Thanks

Way to change dd3 content reference

Hi, first off thank you for this gem.

I have a question.

On the sorting tab, is there a way to define what the 'title' is of the sortable bar. for example I have model with sortable list using the <model_name> #ID for reference. Is there a way to change this so the sortable list is labeled by a specified model attribute, like :maker for example.

It looks like by inspecting the html in the browser its something to do with dd3-content or tree-none.id
`<div class="dd3-content>
Jimmy

`

any help would be greatly appreciated!

couldn't find file 'jstree.nestable'

In rails_admin_nestable(0.0.8), I referred a jstree.nestable.js in my application.js like

//= require 'jquery.nestable'

I am getting the err couldn't find file 'jstree.nestable'.

How to refer this file in my app?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.