19
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails4でactive_adminを使用

Last updated at Posted at 2013-06-05

環境は以下の通りです。
Win7 32bit
Ruby 1.9.3p429
Rails 4.0.0.rc1

使用するGemは以下の通りの指定してください。

Gemfile
gem "jquery-rails", "2.3.0"
gem "formtastic", github: "justinfrench/formtastic"
gem "devise", "3.0.0.rc"
gem 'ransack', github: 'avit/ransack', branch: 'rails4-dependencies'
gem 'activeadmin', github: 'akashkamboj/active_admin', branch: 'rails4'

理由はそれぞれ
jquery-rails → 最近のバージョンではjquery-uiが削除された事により、Active_adminのjs内でエラーを吐くため。

couldn't find file 'jquery-ui'

formtastic → Rails 4ではcheck_box_checked?が削除されたため。

undefined method `check_box_checked?'

devise → Strong_parametersが標準採用となり、attr_accessibleがdeprecateになったため。

attr_accessible is extracted out of Rails into a gem. Please use new recommended protection model for params(strong_parameters) or add protected_attributes to your Gemfile to use old one.

となっています。
たぶん。

後はActive adminからattributeへアクセスするために、以下の様に修正。

config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
end
ActiveAdmin::ResourceController.class_eval do
  # Allow ActiveAdmin admins to freely mass-assign when using strong_parameters
  def resource_params
    [(params[resource_request_name] || params[resource_instance_name]).try(:permit!) || {}]
  end
end
19
19
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
19
19

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?