Activeadmin heroku config sheet config with partial fix

I received the following error message after precompiling my resources locally, and then clicking on the Heroku code:

2012-03-28T17:06:01+00:00 app[web.1]: Started GET "/admin/login" for 67.163.67.203 at 2012-03-28 17:06:01 +0000 2012-03-28T17:06:01+00:00 app[web.1]: 2012-03-28T17:06:01+00:00 app[web.1]: ActionView::Template::Error (File to import not found or unreadable: active_admin/mixins. 2012-03-28T17:06:01+00:00 app[web.1]: Load paths: 2012-03-28T17:06:01+00:00 app[web.1]: /app 2012-03-28T17:06:01+00:00 app[web.1]: /app/vendor/bundle/ruby/1.9.1/gems/activeadmin-0.4.3/app/assets/stylesheets 2012-03-28T17:06:01+00:00 app[web.1]: (in /app/vendor/assets/stylesheets/active_admin.css.scss)): 2012-03-28T17:06:01+00:00 app[web.1]: 7: 2012-03-28T17:06:01+00:00 app[web.1]: 6: <title><%= [@page_title, active_admin_application.site_title].compact.join(" | ") %></title> 2012-03-28T17:06:01+00:00 app[web.1]: 8: <% ActiveAdmin.application.stylesheets.each do |style| %> 2012-03-28T17:06:01+00:00 app[web.1]: 9: <%= stylesheet_link_tag style.path, style.options %> 2012-03-28T17:06:01+00:00 app[web.1]: 10: <% end %> 2012-03-28T17:06:01+00:00 app[web.1]: 11: <% ActiveAdmin.application.javascripts.each do |path| %> 2012-03-28T17:06:01+00:00 app[web.1]: 12: <%= javascript_include_tag path %> 2012-03-28T17:06:01+00:00 app[web.1]: vendor/assets/stylesheets/active_admin.css.scss:2 

...

I tried a bunch of different options, including the following tip I found here: http://mrdanadams.com/2011/exclude-active-admin-js-css-rails/ and others on the GitHub page.

None of these options worked. Ultimately, I got some tips on removing my public / assets directory from git, click on the code in Heroku and let Heroku recompile the assets. This approach partially worked. I no longer receive an error message when I try to go to the / admin page of my site. However, active_admin CSS files are missing. He suspects that since Heroku did the preliminary compilation, this does not cause an error, although the active_admin.css files are not precompiled. How can I get active_admin.css precompiled?

Btw, I am running rails 3.2.

EDIT:

It seems that my โ€œfixโ€ was not complete. If I have require_tree. or require_directory. in my application.css application it works, but it spins my main CSS applications because they are all compiled into application.css. If I do not have one of these entries, then it breaks. Any thoughts on how I can solve this?

+6
source share
6 answers

Finally, I was able to solve this problem. In case someone else runs into this problem, I thought I would document the steps I took to solve this problem.

I ran my application locally in production mode ( RAILS_ENV=production rails s ) and was able to duplicate the error I received on Heroku on my local machine.

I copied my active_admin.css.scss and active_admin.js to the / vendor / assets directory. As the y app kept telling me that it lacked active_admin / mixins, I also copied the entire active_admin directory into the assets in the vendor / assets directory. I'm not sure if this is necessary or not.

From Herokuโ€™s point of view, they told me, but I canโ€™t confirm that production.rb is not read during pre-compilation, so all settings must be defined in application.rb. So, I made sure that I had the following settings in application.rb -

 #Added to fix devise/active admin issue ? config.assets.initialize_on_precompile = false # Precompile additional assets. Defaults to [application.js, application.css, non-JS/CSS] config.assets.precompile += ['active_admin.css.scss', 'active_admin.js'] 

I found most of the tips above around the web (on stackoverflow, heroku, github, etc.). The part I did not see was the need to make changes to Bundler.require in application.rb from:

 Bundler.require(*Rails.groups(:assets => %w(development test))) 

to:

 Bundler.require(:default, :assets, Rails.env) 

Once I made these changes, I could push the code to Heroku and let it pre-assemble the assets for me. Hope this helps someone save time on resolving this issue.

+14
source

You're on the right track by letting Heroku compile assets for you. This makes things easiest.

To include additional files in the precompiler manifest, use something like this in your application configuration (either config/application.rb or config/environments/production.rb ):

 # Precompile additional assets. Defaults to [application.js, application.css, non-JS/CSS] config.assets.precompile += ['active_admin.css', 'active_admin/print.css', 'active_admin.js'] 
+11
source

ActiveAdmin github wiki specifically solves this problem: https://github.com/gregbell/active_admin/wiki/Heroku-Cedar-deployment-with-the-Asset-Pipeline

Here is what he says at the time of writing:


  • Try adding AA assets to the precompilation list in application.rb ( NOTE: you CANNOT add them to production.rb , Heroku DOES NOT read production.rb during precompilation!)

     # config/application.rb config.assets.precompile += %w( active_admin.css active_admin.js active_admin/print.css ) 
  • Try placing active_admin.css.scss and active_admin.js in vendor/assets instead of app/assets . This prevents unintentional inclusion of AA assets when using the sprockets require_tree . directive require_tree . This is the default star chain directive in application.css for the new rails application, which is why many people get confused about the AA assets that are required in all parts of their site. Putting AA assets in vendor/assets prevents this problem, but you can just put it in the app/assets subdirectory and not use the require_tree directive (instead of require_directory instead).

  • Make sure sass-rails is available at precompilation. This implies that during the precompilation, either an asset group or sass-rails is required, available in all gem groups. Often upgrades from older versions of Rails will not have the correct Bundler statement, so it is important to check if the project is running on Rails 3.1+. If you can run bundle exec rake assets:precompile RAILS_ENV=production on your computer without errors and with setting up a fake production base, then you are kind.

  • Configure a hero-specific configuration as indicated in their frequently asked deployment questions using the asset pipeline:

     # config/application.rb - NOT production.rb config.assets.initialize_on_precompile = false 
+7
source

There was the same problem. Fixed by adding the following to production.rb to precompile additional assets:

 config.assets.precompile += %w( active_admin.css active_admin.js) 
+5
source

Instead of storing a list of files, I fixed the problem by changing the flag in production.rb :

 config.assets.compile = true 
+2
source

I found that I can solve this problem by updating my gemfile - moving the "sass-rails" gem from the: assets group to the production or general section.

Apparently, this is a problem when Herok needs a Saas rails stone or he breaks something, so he says: http://ygamretuta.me/2011/10/02/setting-up-active-admin-on-heroku- with-rails-3-1-and-cedar /

0
source

Source: https://habr.com/ru/post/911982/


All Articles