使用 active admin、polyamorous、activerecord 更新 squeel

Posted

技术标签:

【中文标题】使用 active admin、polyamorous、activerecord 更新 squeel【英文标题】:issue updating squeel with active admin, polyamorous, activerecord 【发布时间】:2016-08-02 17:31:53 【问题描述】:

我有一个几年前的项目(rails 4),我正在尝试更新(所有这些都是为了活动管理员的日期时间选择不起作用)——当我注释掉需要更新时把它全部更新好;但是如果我取消注释 squeel 以便它也更新,我会遇到这些依赖问题:

Bundler could not find compatible versions for gem "activerecord":

在 Gemfile 中: act-as-taggable-on 被解析为 4.0.0,这取决于 活动记录 (>= 4.0)

annotate was resolved to 2.7.1, which depends on
  activerecord (< 6.0, >= 3.2)

friendly_id (~> 5.1.0) was resolved to 5.1.0, which depends on
  activerecord (>= 4.0.0)

pg_search was resolved to 1.0.6, which depends on
  activerecord (>= 3.1)

polyamorous was resolved to 1.3.1, which depends on
  activerecord (>= 3.0)

polyamorous was resolved to 1.3.1, which depends on
  activerecord (>= 3.0)

rails (~> 4.2.1) was resolved to 4.2.1, which depends on
  activerecord (= 4.2.1)

rails-erd was resolved to 1.4.7, which depends on
  activerecord (>= 3.2)

random_record was resolved to 0.0.8, which depends on
  activerecord (>= 3.0.0)

squeel was resolved to 0.5.0, which depends on
  activerecord (~> 3.1.0.alpha)

Bundler 找不到 gem "polyamorous" 的兼容版本: 在 Gemfile 中: 多角恋

ransack was resolved to 1.8.1, which depends on
  polyamorous (~> 1.3)

squeel was resolved to 0.8.10, which depends on
  polyamorous (~> 0.5.0)

Bundler 找不到 gem "sass" 的兼容版本: 在 Gemfile 中: bootstrap-sass (~> 3.1.1) 被解析为 3.1.1.1,这取决于 萨斯 (~> 3.2)

activeadmin was resolved to 1.0.0.pre4, which depends on
  bourbon was resolved to 4.0.0, which depends on
    sass (~> 3.3)

sass-rails (~> 4.0.1) was resolved to 4.0.5, which depends on
  sass (~> 3.2.2)

我尝试了几种不同的活动管理员组合,例如:

# gem 'activeadmin', '~> 1.0.0.pre2'
# gem 'activeadmin', github: 'activeadmin'
gem 'activeadmin', github: 'gregbell/active_admin'

# gem 'ransack',             github: 'ernie/ransack'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'formtastic',          github: 'justinfrench/formtastic'
gem 'chosen-rails'
gem 'select2-rails'
gem 'active_admin_datetimepicker'
gem "active_admin-sortable_tree"
gem 'polyamorous', github: 'activerecord-hackery/polyamorous'
gem 'ransack', github: 'activerecord-hackery/ransack'

# gem "squeel"  # Last officially released gem
# gem 'squeel', github: 'activerecord-hackery/squeel'
# gem "squeel", :git => "git://github.com/ernie/squeel.git" # Track git repo

但似乎没有任何效果....

【问题讨论】:

您不会尝试升级到 Rails 5,是吗? 不,对我来说是 4.2 【参考方案1】:

虽然我仍在使用它(Rails 5 升级),但您可能想尝试将 activeresource 显式添加到您的 Gemfile 中。像这样:

gem 'activeresource', github: 'rails/activeresource'

gem 'activeadmin', github: 'activeadmin'
gem 'devise', '~> 3.4.1'

更新确实对我有用,至少到目前为止,并且没有使用其他依赖项,例如 ransack、draper 等,即使建议在他们的(ActiveAdmin 的)官方README 上使用。

试一试。

【讨论】:

以上是关于使用 active admin、polyamorous、activerecord 更新 squeel的主要内容,如果未能解决你的问题,请参考以下文章

如何使用 Active Admin 执行批量操作

使用 active admin、polyamorous、activerecord 更新 squeel

Active Admin 中突然没有方法错误?

rails active admin 部署:找不到文件'jquery-ui'

在视图文件中添加 active_admin_comments 方法

在Active Admin Rails中创建新项目时过滤下拉列表