Impossible to see CKeditor in production - ckeditor

I have a rails 4 app that use CKeditor. In dev mode it works fine but in production ckeditor does not apear and there is a blank space at the location of the textarea.
According to the logs, the following file is missing :
ActionController::RoutingError (No route matches [GET] "/assets/ckeditor/styles.js")
And if i precompile the asset i can see the following file generated :
public/assets/ckeditor/styles-65fee53acf063b3d207bc00b4f7ce0d5.js
Here is the ckeditor line of my application.rb :
config.assets.precompile += Ckeditor.assets
It seems that's the file CKeditor want but it is not looking for the precompiled one. How can i fix that?

i have pre-compiled my assets and pushed my repo to production server and got similar bug. And ckeditor was not loading.
Following worked for me:
1) Under config > environment > productio.rb file there is a line
config.assets.compile = false
i changed false to true and pushed the code to production site. Stopped and started unicorn. That did the trick now ckeditor is loading.
hope that helps.

For Rails 5 you have use in Gemfile
gem 'ckeditor', github: 'galetahub/ckeditor'
look here:
https://github.com/galetahub/ckeditor/issues/719

Did you follow these steps in the Readme? https://github.com/galetahub/ckeditor#usage-with-rails-4-assets

Specifying the CKEditor BasePath in the <head> section of my application.html.erb file fixed my issue
<script type="text/javascript">
var CKEDITOR_BASEPATH = '/assets/ckeditor/';
</script>

I had the same problem, i had included config.assets.compile = true and didnĀ“t work...
Finally i did rake
rake assets:precompile
from the console.
If you are uploading images directly to AWS S3 you need to comment out the carrierwave or paperclip initializer while precompiling.
Then pushed it to production and worked fine!

Related

Rails: application.css not in asset pipeline

I know this is a old question but no answer is fixing my problem.
I'm new to Ruby on Rails and just created project with a PostgreSQL database just to be able to upload the project to Heroku.
When i start the rails server im getting the error "application.css is not present in the asset pipeline."
I'm using bootstrap 4 gem and this requires that you rename the applications.css to application.scss.
I dont know what is wrong.
I really tried every answer that is on stackoverflow without any success :(
Please help me, what am i doing wrong?
This is the error im getting:
Ok, first thing.
Do you have config.serve_static_files = true set in your production.rb file under config/environment folder.
Since we run behind NGINX, in our case it looks like config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Second thing. Did you do rails assets:precompile before the uploading it to the server?
And the third thing is. Have you tried calling your file application.css.scss, and redoing the rails assets:precompile?
Last, and not least thing. How does your application.scss file look like?
Did you remove all those *= and used #import instead for Bootstrap
It is nicely described in the documentation:
Import Bootstrap styles in app/assets/stylesheets/application.scss:
// Custom bootstrap variables must be set or imported before
bootstrap. #import "bootstrap";
And then it says:
Make sure the file has .scss extension (or .sass for Sass syntax). If
you have just generated a new Rails app, it may come with a .css file
instead. If this file exists, it will be served instead of Sass, so
rename it:
$ mv app/assets/stylesheets/application.css
app/assets/stylesheets/application.scss Then, remove all the *=
require and *= require_tree statements from the Sass file. Instead,
use #import to import Sass files.
Do not use *= require in Sass or your other stylesheets will not be
able to access the Bootstrap mixins and variables.
Read more here
origin answer
in my case, I forgot to install yarn command in my server.
so, please install yarn before running rails server. otherwise assets:precompile will do nothing and give no warning.
update
also, make sure all of these things:
file exists: app/assets/stylesheets/application.css
its content looks like:
/* ...
*= require_self
*= require_tree .
*/
also check file app/assets/config/manifest.js,
//= link application.css
To give more clarity to mutantkeyboard's answer
I had this issue when deploying a Rails application as a docker image that would run in a docker container without a web server like Nginx.
Here's how I got it fixed:
This issue is primarily caused in production when you do not want to serve your static files from the /public folder using a web server like Nginx or Apache.
To serve files your static files from the /public folder without using a web server like Nginx or Apache, do the following:
Ensure you precompile your assets using:
bundle exec rails assets:precompile
OR
rails assets:precompile
This will compile your assets into the /public folder
Next, in your config/environments/production.rb file, add the following:
Instead of this:
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
Use this:
config.public_file_server.enabled = true
This allows rails to serve the static files instead of a web server
Note: For improved performance it's best to serve the static files using a Web server like Apache or Nginx.
Just reinstall yarn et precompile our assets:
yarn's parkages don't push on github... to fix this, reinstall yarn:
yarn
and precompile assets:
bundle exec rails assets:precompile
Rails 7.0.4 ruby 3.1.2 I solved issue with yarn build when missing application.js but in case missing application.css just did yarn build:css

Jekyll livereload browser not connecting

I'm not a ruby expert here, and I'm new to jekyll just trying to get the livereload plugin to work on a blank theme.
plugin: https://github.com/RobertDeRose/jekyll-livereload
I setup jeckyll with a blank theme with jekyll new theme --blank When I run jekyll serve, I can see LiveReload Server: http://127.0.0.1:35729 output in terminal so I guess it should be working, but the browser reloading doesn't work. However it does work if I use the default theme.
When using the default theme, there's an extra message: LiveReload: Browser connectedwhen I run jekyll serve. That message doesn't appear with blank theme.
Is there something I'm missing here?
I know this is old, but I was facing the same issue, so I thought I'd share the solution that worked for me.
You just need to add front matter to the top of your html file, that's two triple-dashed lines, so your html file should look like this:
---
---
<!DOCTYPE html>
<html lang="en">

Laravel 5.4 - Bootstrap glyphicons don't work after sass integration

Well, I just installed fresh Laravel 5.4. Then installed npm and decided first time to use webpack instead of gulp.js. As you know, Laravel default provides sass Bootstrap integration. Used this command to generate my css from sass.
npm run dev
Bootstrap, Jquery worked perfect, but Glyphicons weren't displayed. Checking my public/css/app.css I saw, that Glyphicons font-face path are not suitable.
src: url(/fonts/glyphicons-halflings-regular.eot?f4769f9bdb7466be65088239c12046d1);
If I, manually use ../fonts instead of /fonts it will work. I tried to figure out and edit the default path. In _variables.css I set:
$icon-font-path = "../fonts" - but npm gives error.
By default it is: "~bootstrap-sass/assets/fonts/bootstrap/"
Copied fonts folder inside puclic/css folder, didn't work.
Added options to the webpack.mix.js file:
options({processCssUrls: false})
and in _variables.css again set:
$icon-font-path = "../fonts"
Run npm-run-dev and it worked, glyphicons were displayed. But, I don't want to set false for processCssUrls. Because, in this case I will not able to minimize css files using command: npm run production.
Also, I followed this question, but couldn't find any answer, all solutions didn't work.
glyphicons not showing with sass bootstrap integration
Finally, found the solution. In webpack.config.js set:
publicPath: '../'
instead of Mix.resourceRoot
{
test: /\.(woff2?|ttf|eot|svg|otf)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]?[hash]',
publicPath: Mix.resourceRoot
}
},

gulp build/firebase deploy won't transfer images or videos

I am trying to deploy my application, which works fine locally. When I use gulp build it says I have all of the files I need. When I do firebase deploy it says that everything uploaded. However, when I use firebase open it makes
it gives me the following 404 errors.
Here is what comes up when I do gulp build and firebase deploy
I can send the gulp-babel.js file upon request. Thanks in advance for looking.
If I am understanding you correctly, you are having a problem with your gulp-babel.js file. The gulp imagemin plugin is probably what you need.
https://www.npmjs.com/package/gulp-imagemin
Then somewhere in that file make sure you are creating something like this.
gulp.task('images', () => {
return gulp.src('app/images/*')
.pipe($.imagemin({
progressive: true,
svgoPlugins: [{removeViewBox: false}]
}))
.pipe(gulp.dest('dist/images'));
})
See this if you have gulp-load-plugins: gulp-load-plugins not loading plugins

Heroku not loading Google fonts

I'm running a site on Heroku, and having some troubles getting a google font to load.
My typography.sass file contains this:
#import url(http://fonts.googleapis.com/css?family=Bitter)
h1
font-family: 'Bitter', Helvetica, serif
My production.rb file contains the lines:
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
My Gemfile includes:
gem 'rails_12factor', group: :production
I've gone through all the Heroku issues with the asset pipeline, and I've gotten all of my images and css files to load properly in production, but for whatever reason, the font only works in development.
I had the same problem and found this answer:
https://stackoverflow.com/a/18216759
It appears that Heroku wants https. So throwing in https solved the problem for me.
I used to have the same issue but deleting the assets folder located in the public folder solved the problem for me. This will let Heroku precompile the css files for you and not use the files generate by running rake assets:precompile locally.
This fellow seemed to have a similar problem to yourself:
http://robert-reiz.com/2012/11/16/google-fonts-on-heroku/
Try his method of fixing it and see if that works. Good luck!

Resources