0

I have created service for live chat using Ajax and Rails, where I send ajax GET requests to server and receive responds . Anyway, I want that Ajax script works on every page except on home/chat. So, I have chat.js file and I include it in application.html like follow:

title Online Mental Health
 = stylesheet_link_tag 'application', :media => "all"
 = csrf_meta_tags
 = javascript_include_tag 'application'
 - unless params[:controller] == 'home' 
   = javascript_include_tag 'chat.js' 

Also, I added in staging.rb and production.rb this :

 config.assets.precompile += %w( chat.js )

And I didn't include my chat.js file into application.js .

But when I deploy my application on server, and do

 RAILS_ENV=staging bundle exex rake assets:precompile

I am getting error as bellow:

Sprockets::Helpers::RailsHelper::AssetPaths::AssetNotPrecompiledError in Dashboards#user_view

chat.js isn't precompiled

Extracted source (around line #10):

7:     / = render 'shared/chat_javascript_include'
8:     = javascript_include_tag 'application'
9:     - unless params[:controller] == 'home' 
10:       = javascript_include_tag 'chat.js' 
11:   body
12:     = render 'forum_areas/header'
13:   - if current_user.present?

Any help is appreciated. Thanks

2
  • config.assets.compile = true did you try this Commented Jul 27, 2014 at 12:54
  • Yes, that's solve my problem . But I think that's not good practice to set assets.compile on true because performances ? Commented Jul 27, 2014 at 15:26

1 Answer 1

1

I make my comment as a post for any one use it

Please do this in your environment file(staging.rb , production.rb)

config.assets.compile = true

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.