Sorry in advance, I know there are topics on this subject, but this is maddening! I wouldn't be as frustrated if this problem wasn't limited to just the index. The CSS loads fine all on the pages of my app except the post/index page. I should note it runs perfectly locally and I've been banging my head against this since this morning so I may have overlooked something banal and apologize in advance.
Gem file
gem 'rails_12factor', group: :production
gem 'pg', group: :production
Production.rb
config.cache_classes = true
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true
Running the following was unsuccessful:
RAILS_ENV=production bundle exec rake assets:precompile
bundle exec rake assets:precompile
Specifying while assets to precompile in production.rb was unsuccessful
config.assets.precompile += %w( public.css public.js )
config.assets.precompile += %w( assets/stylesheets )
Also tried changing the extensions from .css to .scss and adding a new custom.scssand linking to it without success.
Link to my app and the page in question:
https://clickbait22.herokuapp.com/
Link to its Github repository:
https://github.com/4thking/clickbait
Try running...
heroku run bundle exec rake assets:precompile
heroku open
In production, you must run rake assets:precompile to serve up anything in your app/assets folder. In development mode, Rails constantly checks for updates to the files and serves them each one separately.
It is nice when you're developing, but is quite slow in production. So, to speed things up, Rails has you run a single, longer task that shrinks and combines a bunch of files in app/assets, speeding up page loading times and reducing server load.
Hope this helps you out!
UPDATE:
Whilst you said that you have tried doing the following, I want to include it for clarity regardless. Quite often it is important to precompile your assets before you push to Heroku. Inside the terminal this process would look similar to this...
rake assets:precompile
git commit -m 'Assets precompiled'
git push heroku master
Related
I can't serve a jekyll site locally and I get notified that there is a problem with GitHub pages when I commit to GitHub.
bundle exec jekyll -v 11:28:34
jekyll 3.7.3
ruby --version 11:28:42
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
When I run:
bundle exec jekyll serve
will fail and spit out hundreds (more like thousnads) of error messages starting with:
bundler: failed to load command: jekyll (/usr/local/bin/jekyll)
SystemStackError: stack level too deep
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:106:in `new'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/base.rb:106:in `add_text'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/html.rb:171:in `parse_raw_html'
/usr/local/lib/ruby/gems/2.5.0/gems/kramdown-1.17.0/lib/kramdown/parser/kramdown/html.rb:60:in `handle_kramdown_html_tag'
From what I could tell, this can sometimes happen if you use jekyll serve as opposed to bundle exec jekyll serve and if there is a mismatch between your version of jekyll and the one required by github pages, but here I do use bundle exec and so the correct version of jekyll is used.
jekyll itself works if i try to create a new site with jekyll new blah and i can serve that one locally without a problem, but the combo of jekyll and github pages is giving me grief.
I am puzzled and do not know how to proceed.
All this is on Mac OS X 10.13.6.
Not relating to the original cause of the problem here, but i stumbled upon this and had the error stack level too deep. So i guess this might help someone.
I traced my problem to a field that i named as max in some yaml dictionary in the front matter. Maybe you have named a field which has a special meaning in jekyll.
RAIL_ENV= testing or development server looks proper, but on production server not show proper GUI
As per the images shared it seems that the css and styling is not working in production environment.
For it to work, following command would be used:
RAILS_ENV=production rake assets:precompile
Reload the page and check if the css and js rules are being picked or not.
If you're using heroku perhaps you could try it on heroku. First run RAILS_ENV=production rake assets:precompile then run git add . within your working folder. Commit, push and then push to heroku master. See if you still have this issue.
I've set up my site to build with Travis CI, and added a few plugins.
This is my Gemfile:
source "https://rubygems.org"
group :jekyll_plugins do
gem "github-pages"
gem "octopress-minify-html" # This one does not work on Travis
gem "jekyll-git_metadata"
gem "jekyll-paginate-v2"
gem "jekyll-tagging"
end
And this is my .travis.yml (with irrelevant information stripped)
language: ruby
cache: bundler
sudo: false
#install: use default `bundle install`
script: bundle exec jekyll build
after_success: .travis/deploy.sh
I tried building my site locally:
$ bundle update
$ bundle install
$ bundle exec jekyll build
And I can see the generated HTML files are minified.
But when I check pushed files from Travis CI, the HTML files are not minified. Also judging from build time, the plugin octopress-minify-html is not working (when it's working the build time is significantly longer).
I tried deleting my whole working directory and re-cloning from GitHub and this plugin is still working locally. I deleted Travis CI cache and let Bundler build everything again, but the plugin still doesn't work on Travis.
What went wrong on Travis?
You can force minification with octopress-minify-html by setting minify_html: true in your config file.
this's a super noob question but, what exactly is "build the site" running this command:
`~/myblog $ bundle exec jekyll serve`
is this to start the server?, because I'm currently using $ jekyll serve :s
As mentioned in its Quick-start guide, this command will build the site on the preview server.
Update:
There is a difference between jekyll serve and bundle exec jekyll serve:
The Gemfile and Gemfile.lock files inform Bundler about the gem requirements in your site. If your site doesn’t have these Gemfiles, you can omit bundle exec and just run jekyll serve.
When you run bundle exec jekyll serve, Bundler uses the gems and versions as specified in Gemfile.lock to ensure your Jekyll site builds with no compatibility or dependency conflicts.
Update 2:
In simple words, "build the site" means the Bundler will use the gems and versions specified in Gemfile.lock to ensure your Jekyll site builds with no compatibility or dependency conflicts and then will run your site on the preview or local server.
The serve command is actually an extension of the build command.
i.e., when a Jekyll user runs jekyll serve or bundle exec jekyll serve, Jekyll first runs the jekyll build command internally and then starts the local server to host the generated site.
So what exactly is this build the site? Well, Jekyll being a static-site generator generates your site using the build command.
Therefore, whether you run jekyll build or jekyll serve, a default jekyll site gets built or generated into the ./_site folder. The minor difference with running the serve command being Jekyll will proceed to start a local web-server and mount the built / generated site onto the server so that you can navigate the site via http://localhost:4000
I'm seeding a development database (mysql) using rake db:seed in Rails 3. The rake task fails, stating,
Validation failed: Logo /var/folders/.../logo.png is not recognized by the 'identify' command.
When I run which identify, I get the expected path /usr/local/bin/identify. ImageMagick is indeed installed (via Homebrew), and appears to work with png images just fine from the command line.
I even rebuilt the app on another machine, thinking that my environment is borked, and I got the same error.
Is there a poltergeist in my terminal sessions?
Have you tried running a bundle exec before the rake. In the past this has often solved these sorts of problems for me. It will ensure your rails environment is loaded before running the rake task.
bundle exec rake db:seed
Hope that helps!
// Addition
Also are you using the Paperclip gem to do this import? I do remember that I needed to ensure the path to ImageMagick was set in my development.rb file to ensure this was picked up.
Eg.
Paperclip.options[:command_path] = "/usr/local/bin"