Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

should i add a routes.rb to the assets_path? #146

Closed
huobazi opened this issue May 7, 2015 · 8 comments
Closed

should i add a routes.rb to the assets_path? #146

huobazi opened this issue May 7, 2015 · 8 comments

Comments

@huobazi
Copy link

huobazi commented May 7, 2015

I want to use mina for deploy my rails app,
and a see mina use diff to check if the files was changed

https://github.com/mina-deploy/mina/blob/3743585210c6687a8c9c18ca6bfc8a28204d674a/lib/mina/rails.rb#L197

so i think if i should add the routes.rbto assets path

http://nadarei.co/mina/docs/lib/mina/rails.html#asset-paths
https://github.com/mina-deploy/mina/blob/master/lib/mina/rails.rb#L53

should do a assets.paths?

Rails.application.config.assets.paths << Rails.root.join("config", "routes.rb")

or only setting it in mina

set_default :asset_paths, ['vendor/assets/', 'app/assets/','config/routes.rb']

any response will be greatly appreciated.

@andrewhavens
Copy link
Contributor

@huobazi Your config/routes.rb has nothing to do with assets. You should not add config/routes.rb as an asset path.

@huobazi
Copy link
Author

huobazi commented May 10, 2015

@aaronjensen if i add a new route or change a route, the path the xxx_uath() in routes.js will be changed
but the gem mina dose not know the routes.js was changed, bucause it use diff to check if the files was changed

@le0pard
Copy link
Member

le0pard commented May 10, 2015

I don't know how it handle mina, but capistrano handle changed assets by running every time rake task assets:precompile, which handle what files changed and what didn't (by folder cache).

@huobazi
Copy link
Author

huobazi commented May 11, 2015

@le0pard
mina handle changed assets by diff the asset_paths
if the asset_paths NOT CHANGE mina skip the rake task assets:precompile and copy the last version files to public folder
https://github.com/mina-deploy/mina/blob/3743585210c6687a8c9c18ca6bfc8a28204d674a/lib/mina/rails.rb#L197

@le0pard
Copy link
Member

le0pard commented May 11, 2015

I think, it is problem of mina, because in this case, if you have erb code in js - it also will not run this task. Example:

var SomeVar = <%= TIMEZONES_CONSTANTS.to_json %>

If you will change constant TIMEZONES_CONSTANTS in Ruby - this code will not change, but should be recompiled. js-routes have hook https://github.com/railsware/js-routes/blob/master/lib/js_routes/engine.rb#L17 which check config/routes.rb for changes to recompile by asset:precompile task.

So answer very simple: config/routes.rb has nothing to do with assets. You should not add config/routes.rb as an asset path. You should fix this problem by mina. (as wrote @andrewhavens)

@andrewhavens
Copy link
Contributor

@huobazi @le0pard Ironically, I just ran into this issue in a different context. We are working on some Cucumber tests and Capybara sets a different port for the app to run on every test run. Since the routes.js.erb is an .erb file, the file is cached in the asset pipeline, even though we are dynamically setting a different port on every test run. The solution for us so far has been to run the tmp:cache:clear rake task on every test run. But I'm not sure if this is a suitable solution for production deployments.

@d4be4st
Copy link

d4be4st commented Jul 5, 2015

this is a mina problem. It uses a diff to see if any assets files have been changed before attempting to precompile them.

There are two solutions:

  1. Add a new empty line to your js files
  2. use invoke :'rails:assets_precompile:force' insteead of invoke :'rails:assets_precompile' in your deploy.rb script

@bogdan
Copy link
Collaborator

bogdan commented Jul 5, 2015

Maybe you can run force vs not force based on if there are changes in routes.rb. If it is possible in mina, it should help you.

@le0pard le0pard closed this as completed Aug 30, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants