Rails 3.1 on heroku ckeditor - ruby-on-rails

I have a big problem with the ckeditor "3.7.0.rc2" gem.
In development it works great with s3 a backend for uploading.
But on heroku it does not work.
The problem is that the ckeditor/vendor/skins/(kama) or (office2003) or (v2) /editor.css files contains an error that makes the sass compiler scream. The error like this "filter:;", since there is no value it does not work.
There is no point in change the files locally, because heroku downloads the gem as I deploy.
I have tried to package the gem locally and make my own git fork and install it for there. But, then the
RAILS_ENV=production bundle exec rake assets:precompile
command precompiles all files in the ckeditor folders and always ends in
rake aborted! Permission denied
When I precompile with the "3.7.0.rc2" gem installed, some ckeditor js files are precompiled but not all.
How can I get around this problem?

When you fork ckeditor gem and use the forked git path in Gemfile heroku will pull the sources of ckeditor from your forked git repo instead of the gem. This should fix the issue.
Other thing that you could try is precompile the assets in your development machine and push the assets to heroku. This will make sure that heroku will not precompile those assets. More info is available at http://devcenter.heroku.com/articles/rails31_heroku_cedar. This will run only on cedar stack

The solution was to fork the git repo, delete all unnecesarry and correct the errors. js files. Then the precompiling worked and now the app is running on heroku.
Here's a link to my fork https://github.com/andreaslyngstad/ckeditor
It worked in my project, but I have deleted js files that I did not use, so if you are using some of them, this is not for you.

Related

Rails on Heroku - Site does not load - ActionView::Template::Error (The asset "image.jpg" is not present in the asset pipeline.)

I've build a simple website, using Rails so I can deploy it to Heroku. It runs perfectly locally, everything works fine. It deploys fine to Heroku but when opening the webpage (http://a-clean.herokuapp.com/) I get the following error displayed:
We're sorry, but something went wrong.
If you are the application owner check the logs for more information.
When I check the logs (running heroku logs in terminal) it shows the error:
ActionView::Template::Error (The asset "a_clean_sample_1.jpg" is not present in the asset pipeline.)
So far this is just a one-page website with a couple of partials. Here is the github repository: https://github.com/webbc99/a-clean
The image it's failing on is loaded in app/views/welcome/home.html.erb line 57.
Rails version 5.1.6, Ruby version 2.5.0
I've double checked that the images are in fact in the app/assets/images folder, and the image_tags are using the file extensions.
I've tried running heroku run rake assets:precompile, and I've tried using the rails12factor gem and also without it. I have tried changing config.assets.compile = false to true in the config/environments/production.rb which did get the page to load but all of the images were ignoring styling and were huge.
What is really confusing me is that I have deployed several other rails apps, same rails version, same ruby version, and none of these have had this issue before.
Here is a working app:
https://github.com/webbc99/presumptuous
https://presumptuous.herokuapp.com/
Any help would be greatly appreciated, been googling this for hours with no luck.
It's the simplest way to fix this problem is; You need to run as follows;
rails assets:precompile RAILS_ENV=production
git add .
git commit -m {message}
git push heroku master (push the code to the heroku again)
I tried to do it from your code and work fine.

Correct procedure to change location of asset compilation with Heroku

I want to change from having Heroku pre-compile the assets to pre-compiling them on development and pushing them to Heroku. I understand the basic procedure is
RAILS_ENV=production bundle exec rake assets:precompile
git add .
git commit -m 'Add precompiled Assets'
git push production master
However, this wipes out any existing assets on heroku. For instance, images referenced in old emails are wiped out. Is there a way to do this and provide a continuity with legacy assets?
Based on some help from Heroku support and the comments from Schneems below, here is the non-answer I came to.
Unless you understand the intricacies of managing your assets with sprockets, precompile on heroku rather than locally.
Whether you precompile locally or heroku, use a CDN and set far future expire dates on your assets.
Use the latest version of sprockets (3.7.1 as the time of writing this post).
If you precompile locally, be aware that sprockets does keep the last three copies of the assets around, and keep in mind it is up to you to keep your assets consistent with the last release.
There are many edge cases, so there is no such thing as a simple answer that suits the stack overflow format.
So in summary, unless you are highly knowledgeable or courageous, do not precompile locally.
And finally, use a CDN.

Can I force Heroku to compile the assets?

I used to develop a project on my own and now I have got some others to help in the project. It's developed with Ruby on Rails and we have a staging server on Heroku. Beforehand the deployment workflow is to precompile the assets in local machine then push the code to heroku. It works well when I am on my own.
Now I am working with a Front-end engineer. The problem is we are working in different location so it is difficult to setup his computer the same as mine. As a result, he will not be able to precompile the code before pushing to heroku.
Of course I can do it for him but would be better if he can just submit the code to the staging server and let Heroku to precompile it. I think Heroku detect if the manifest file is available to determine if it needs to precompile. Is there a way to force Heroku to recompile the assets?
I have tried: heroku run rake assets:clean then heroku run rake assets:precompile but no luck...
Heroku's servers use a read-only file system. This is how they make it easy for you to spin up more dynos, among other things.
Compiling Rails assets means taking the source files and compiling a new file, i.e. writing a file to the file system. Since this can't happen on a read-only file system, you have to precompile first. Even if you did manage to compile assets on Heroku, by writing to the /tmp directory, at the end of the day when Heroku reboots dynos, your new files will be gone because they weren't checked into the repo as they would've been if you had precompiled them locally, committed them, and then pushed to Heroku.
Any workaround I can imagine would be more complicated than helping your front end dev setup Rails and bundle installing the gems needed to precompile before pushing.

Heroku Assests Precompile Issue

Recently I upgraded ruby version of my Heroku application after which it stopped compiling assets.
Initially I was using ruby version 1.9.2 and my assets were getting compiled while deploying the application. Recently I upgraded ruby version to 1.9.3 by specifying in gem file and adding config variable "RUBY_VERSION" for my application.
Everything is working fine now it is also picking right ruby version but it is not running assets precompile command while deploying application.
I have following line in application.rb
config.assets.enabled = true
A quick 'fix' for this would be precompiling the assets locally and then deploying the application.
I think its better, for a faster deployment.
First
rake assets:clean
then
RACK_ENV=production rake assets:precompile

Deploying a modified vendor asset to Heroku

I have Jquery-datatables-rails gem installed. When you install the gem via bundle a folder is created under .rvm/gems/RUBY#GEMSET/gems/jquery-datatables-rails
Inside of this folder you can browse to the vendor/assets folder and modify the CSS, etc.
The only problem is that upon deployment a remote version of the gem is installed on the remote production instance, which does not reflect the local changes.
Is there any way to ensure the local modifications are pushed to Heroku?
Thanks
You can fork the gem and point to it on github as you mentioned, or you can make the changes to your local assets directory which will speed up the time it takes to compile your app on Heroku.

Resources