9
20

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.

active_adminのCSS/JavaScript置き場

Last updated at Posted at 2018-03-03

active_admin は便利なんだけど、assets がアプリケーション全体に影響を与えてしまうのが困りもの。

その回避策としてよく見るのは、

app/assets/stylesheets/
├ public/
│├ application.css
│└ ...
└ admin/
 └ active_admin.css

みたいなファイルレイアウトにしてごにょごにょするというものなんだけど、ちょっとかっこ悪いので、

vendor/assets
├ stylesheets/
│└ active_admin.scss
└ javascripts/
 └ active_admin.js.coffee

というファイルレイアウトにして、

config/application.rb で

config.assets.paths << config.root.join("vendor/assets/javascripts")
config.assets.paths << config.root.join("vendor/assets/stylesheets")

config/initializers/active_admin.rb で

config.clear_stylesheets!
config.register_stylesheet 'active_admin.css'

config.clear_javascripts!
config.register_javascript 'active_admin.js'

という感じにしてみた。

うむ、悪くない (。◉ᆺ◉)

9
20
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
9
20

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?