2
votes

I have a bug in my simple rails 4.2.5 application I am ruining the app on windows. I have active admin gem and was working fine up to yesterday after I followed the tutorial here to Exclude active_admin JS and CSS from loading in the Rails app. I will repeat what the tuturial says here just in case the link changes:

Create the folders app/assets/javascripts/admin and app/assets/stylesheets/admin and move the files active_admin.js and active_admin.css.scss into these folders, respectively.

Create the folders app/assets/javascripts/admin and app/assets/stylesheets/admin and move the files active_admin.js and active_admin.css.scss into these folders, respectively.

In your app/assets/stylesheets/application.css.scss you will find the following near the top:

 *= require_self
 *= require_true .

Change this to:

 *= require_self
 *= require_directory .

Do the same for application.js.

Re-including the files in active admin The culprit is active_admin’s asset_registration.rb and application.rb:

def register_default_assets
  register_stylesheet 'active_admin.css'
  register_javascript 'active_admin.js'
end

To clear these and replace them with the new files, add the following to the bottom of config/initializers/active_admin.rb:

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

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

Heroku deployment problems When deploying to heroku, you may see something like this in the logs:

Started GET "/admin/login" for 146.115.108.146 at 2011-12-22 16:03:32 +0000

ActionView::Template::Error (admin/active_admin.css isn't precompiled):
    6:   <title><%= [

    7: 
    8:   <% ActiveAdmin.application.stylesheets.each do |path| %>
    9:     <%= stylesheet_link_tag path %>
    10:   <% end %>



    12:     <%= javascript_include_tag path %>
    11:   <% ActiveAdmin.application.javascripts.each do |path| %>

The files need to be precompiled for production, as noted in this issue. Add the following to application.rb (or config file of choice):

config.assets.precompile += %w[admin/active_admin.css admin/active_admin.js]

I did exactly what in that tutorial but I got a very strange error with this Chinese characters when I access http://localhost:3000/admin it redirect to http://localhost:3000/admin/login and show this error 757 unexpected token at:...(I could not paste the error as text because of stack overflow spam filter does not allow Chinese characters.) enter image description here enter image description here

in base.js.coffee:

#= require jquery
#= require ./jquery_ui
#= require jquery_ujs
#= require_self
#= require_tree ./lib
#= require_tree ./ext
#= require ./application

window.ActiveAdmin = {}

any ideas please?

1
Can you show the contents of your base.js.coffee file? - Undo
Please do not use images to convey required information in the question. Images are difficult to read and their links rot then break making the question worthless. Copy and paste the necessary information into your question, reducing it to be concise. Also, please write a more useful title that explains the problem more clearly; "rails app very weird error" tells us nothing. The more effort into explaining and asking your question the better we can help you. Please read "How to Ask", along with the links on that page. - the Tin Man
I have tried to post as text but stackoverflow spam system did not allow me because it contains chines characters! - ukeagle
Because, for good or bad, SO is an English-based system. All the more reason to not use an image; You'll get more help using English. - the Tin Man
how can I use English? this is an error produced by the system in Chinese for a unknown reson! - ukeagle

1 Answers

2
votes

After very hard work this was the solution for me:

in config/initializers/active_admin.rb: change this:

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

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

to this :

config.clear_stylesheets!
config.register_stylesheet 'admin/active_admin'

config.clear_javascripts!
config.register_javascript 'admin/active_admin'

in config/initializers/assets.rb add:

Rails.application.config.assets.precompile += %w( admin/active_admin.js )
Rails.application.config.assets.precompile += %w( admin/active_admin.css )

config/application.rb removed:

   config.assets.precompile += %w( /admin/active_admin.css.scss )
    config.assets.precompile += %w( /admin/active_admin.js.coffee )