Bootstrap social rails buttons displays properly offline, but not on heroku - css

My buttons appear fine offline, but when I push them to Heroku, the padding is off. Has anyone else experienced this?
config/environments/development.rb
Rails.application.configure do
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = true
config.action_controller.perform_caching = false
config.action_mailer.raise_delivery_errors = true
config.active_support.deprecation = :log
config.active_record.migration_error = :page_load
config.assets.debug = true
config.assets.digest = true
config.assets.raise_runtime_errors = true
end
config/environments/development.rb
Rails.application.configure do
config.serve_static_files = true
config.serve_static_assets = true
config.cache_classes = false
config.eager_load = false
config.consider_all_requests_local = false
config.action_controller.perform_caching = false
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = true
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
assets/stylesheets/application.css
/*
* Unimportant comments
*
*= require_tree .
*= require_self
*= require font-awesome
*= require bootstrap-social
*/
On heroku:
http://i.imgur.com/8X6RTdk.png
Offline
http://i.imgur.com/dL6pdBC.png
I've ran rake assets:precompile before I push and still the same outcome. All suggestions are welcome.
EDIT
Here's my Gemfile (I realize I have duplicate gems):
source 'https://rubygems.org'
ruby '2.2.0'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use postgresql as the database for Active Record
gem 'pg'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'turbolinks'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'devise'
gem 'rails_12factor', group: :production
gem 'twitter-bootstrap-rails'
gem 'simple_form'
gem 'puma'
gem 'omniauth-facebook'
gem 'omniauth-google-oauth2'
gem 'font-awesome-rails'
gem 'bootstrap-social-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :production, :staging do
gem 'pg'
gem 'rails_12factor'
end
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end

Related

ActionView::Template::Error (Webpacker can't find application in /app/public/packs/manifest.json

i've tried many suggestions and answers from all around the web and something is just missing.
I keep getting the above error while trying to open my app (which works perfectly locally) on Heroku.
I've followed the standard instructions for deploying an app using git and heroku cli.
I have pushed everything to heroku but while trying to visit my site via the html i keep getting "We're sorry, but something went wrong." and the console shows this error:
2020-09-22T12:29:49.151911+00:00 heroku[router]: at=info method=GET path="/" host=thawing-retreat-03527.herokuapp.com request_id=eac8d868-4c14-4c1d-be40-0741778518c7 fwd="83.130.59.73" dyno=web.1 connect=0ms service=27ms status=500 bytes=1827 protocol=https
2020-09-22T12:29:49.410973+00:00 heroku[router]: at=info method=GET path="/favicon.ico" host=thawing-retreat-03527.herokuapp.com request_id=3b73846f-7d13-4159-b33b-be26db60b209 fwd="83.130.59.73" dyno=web.1 connect=0ms service=6ms status=200 bytes=143 protocol=https
2020-09-22T12:53:00.330777+00:00 app[web.1]: I, [2020-09-22T12:53:00.330645 #4] INFO -- : [9d66d3df-99bc-4899-93d2-a203bddc9291] Started GET "/" for 83.130.59.73 at 2020-09-22 12:53:00 +0000
2020-09-22T12:53:00.332093+00:00 app[web.1]: I, [2020-09-22T12:53:00.332025 #4] INFO -- : [9d66d3df-99bc-4899-93d2-a203bddc9291] Processing by PagesController#about as HTML
2020-09-22T12:53:00.334335+00:00 app[web.1]: I, [2020-09-22T12:53:00.334265 #4] INFO -- : [9d66d3df-99bc-4899-93d2-a203bddc9291] Rendering pages/about.html.erb within layouts/application
2020-09-22T12:53:00.335195+00:00 app[web.1]: I, [2020-09-22T12:53:00.335130 #4] INFO -- : [9d66d3df-99bc-4899-93d2-a203bddc9291] Rendered pages/about.html.erb within layouts/application (Duration: 0.7ms | Allocations: 141)
2020-09-22T12:53:00.336616+00:00 app[web.1]: I, [2020-09-22T12:53:00.336554 #4] INFO -- : [9d66d3df-99bc-4899-93d2-a203bddc9291] Completed 500 Internal Server Error in 4ms (Allocations: 839)
2020-09-22T12:53:00.338353+00:00 app[web.1]: F, [2020-09-22T12:53:00.338286 #4] FATAL -- : [9d66d3df-99bc-4899-93d2-a203bddc9291]
2020-09-22T12:53:00.338354+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] ActionView::Template::Error (Webpacker can't find application in /app/public/packs/manifest.json. Possible causes:
2020-09-22T12:53:00.338357+00:00 app[web.1]: 1. You want to set webpacker.yml value of compile to true for your environment
2020-09-22T12:53:00.338357+00:00 app[web.1]: unless you are using the `webpack -w` or the webpack-dev-server.
2020-09-22T12:53:00.338358+00:00 app[web.1]: 2. webpack has not yet re-run to reflect updates.
2020-09-22T12:53:00.338359+00:00 app[web.1]: 3. You have misconfigured Webpacker's config/webpacker.yml file.
2020-09-22T12:53:00.338359+00:00 app[web.1]: 4. Your webpack configuration is not creating a manifest.
2020-09-22T12:53:00.338360+00:00 app[web.1]: Your manifest contains:
2020-09-22T12:53:00.338361+00:00 app[web.1]: {
2020-09-22T12:53:00.338362+00:00 app[web.1]: }
2020-09-22T12:53:00.338362+00:00 app[web.1]: ):
2020-09-22T12:53:00.338363+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 6: <%= csp_meta_tag %>
2020-09-22T12:53:00.338364+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 7:
2020-09-22T12:53:00.338365+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 8: <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
2020-09-22T12:53:00.338365+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 9: <%= javascript_pack_tag 'application', 'data-turbolinks-track': 'reload' %>
2020-09-22T12:53:00.338366+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 10: </head>
2020-09-22T12:53:00.338366+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 11:
2020-09-22T12:53:00.338367+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] 12: <body>
2020-09-22T12:53:00.338367+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291]
2020-09-22T12:53:00.338368+00:00 app[web.1]: [9d66d3df-99bc-4899-93d2-a203bddc9291] app/views/layouts/application.html.erb:9
I think I made a mistake while making this app bootstrap friendly. Or maybe something is wrong with my files.. I'm truly lost at this point.
These are my files:
package.json:
{
"name": "project",
"private": true,
"dependencies": {
"#rails/actioncable": "^6.0.0",
"#rails/actiontext": "^6.0.3-2",
"#rails/activestorage": "^6.0.0",
"#rails/ujs": "^6.0.0",
"#rails/webpacker": "4.3.0",
"bootstrap": "^4.5.2",
"jquery": "^3.5.1",
"popper.js": "^1.16.1",
"trix": "^1.2.0",
"turbolinks": "^5.2.0",
"webpack": "^4.0.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.11.0"
}
}
application.js:
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("#rails/ujs").start()
require("turbolinks").start()
require("#rails/activestorage").start()
require("channels")
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
require("trix")
require("#rails/actiontext")
//= require jquery3
//= require popper
//= require bootstrap
import 'bootstrap'
import '../stylesheets/style'
style.scss:
#import "bootstrap";
webpacker.yml:
# Note: You must restart bin/webpack-dev-server for changes to take effect
default: &default
source_path: app/javascript
source_entry_path: packs
public_root_path: public
public_output_path: packs
cache_path: tmp/cache/webpacker
check_yarn_integrity: false
webpack_compile_output: true
# Additional paths webpack should lookup modules
# ['app/assets', 'engine/foo/app/assets']
resolved_paths: []
# Reload manifest.json on all requests so we reload latest compiled packs
cache_manifest: false
# Extract and emit a css file_
extract_css: false
static_assets_extensions:
- .jpg
- .jpeg
- .png
- .gif
- .tiff
- .ico
- .svg
- .eot
- .otf
- .ttf
- .woff
- .woff2
extensions:
- .mjs
- .js
- .sass
- .scss
- .css
- .module.sass
- .module.scss
- .module.css
- .png
- .svg
- .gif
- .jpeg
- .jpg
development:
<<: *default
compile: true
# Verifies that correct packages and versions are installed by inspecting package.json, yarn.lock, and node_modules
check_yarn_integrity: true
# Reference: https://webpack.js.org/configuration/dev-server/
dev_server:
https: false
host: localhost
port: 3035
public: localhost:3035
hmr: false
# Inline should be set to true if using HMR
inline: true
overlay: true
compress: true
disable_host_check: true
use_local_ip: false
quiet: false
pretty: false
headers:
'Access-Control-Allow-Origin': '*'
watch_options:
ignored: '**/node_modules/**'
test:
<<: *default
compile: true
# Compile test packs to a separate directory
public_output_path: packs-test
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile: false
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
application.html.erb:
// This file is automatically compiled by Webpack, along with any other files
// present in this directory. You're encouraged to place your actual application logic in
// a relevant structure within app/javascript and only use these pack files to reference
// that code so it'll be compiled.
require("#rails/ujs").start()
require("turbolinks").start()
require("#rails/activestorage").start()
require("channels")
// Uncomment to copy all static images under ../images to the output folder and reference
// them with the image_pack_tag helper in views (e.g <%= image_pack_tag 'rails.png' %>)
// or the `imagePath` JavaScript helper below.
//
// const images = require.context('../images', true)
// const imagePath = (name) => images(name, true)
require("trix")
require("#rails/actiontext")
//= require jquery3
//= require popper
//= require bootstrap
import 'bootstrap'
import '../stylesheets/style'
Gemfile:
source 'https://rubygems.org'
git_source(:github) { |repo| "https://github.com/#{repo}.git" }
ruby '2.7.1'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.3', '>= 6.0.3.2'
# Use sqlite3 as the database for Active Record
group :development do
gem 'sqlite3', '~> 1.4'
end
group :test, :production do
gem 'pg'
end
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Use SCSS for stylesheets
gem 'sass-rails', '>= 6'
# Transpile app-like JavaScript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use Redis adapter to run Action Cable in production
# gem 'redis', '~> 4.0'
# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Active Storage variant
gem 'image_processing', '~> 1.2'
#### custom gem area
gem 'bootstrap', '~> 5.0.0.alpha1'
gem 'sprockets-rails', :require => 'sprockets/railtie'
gem 'jquery-rails'
gem 'devise'
gem 'simple_form'
gem 'faker'
gem 'will_paginate'
gem 'validates_timeliness', '~> 5.0.0.beta1'
gem 'solargraph', group: :development
gem 'rubocop', group: :development
####
# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
end
group :development do
# Access an interactive console on exception pages or by calling 'console' anywhere in the code.
gem 'web-console', '>= 3.3.0'
gem 'listen', '~> 3.2'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
gem 'spring-watcher-listen', '~> 2.0.0'
end
group :test do
# Adds support for Capybara system testing and selenium driver
gem 'capybara', '>= 2.15'
gem 'selenium-webdriver'
# Easy installation and use of web drivers to run system tests with browsers
gem 'webdrivers'
end
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
Manifest.json:
{
"application.js": "/packs/js/application-0da4851a98444f0352a0.js",
"application.js.map": "/packs/js/application-0da4851a98444f0352a0.js.map",
"entrypoints": {
"application": {
"js": [
"/packs/js/application-0da4851a98444f0352a0.js"
],
"js.map": [
"/packs/js/application-0da4851a98444f0352a0.js.map"
]
}
}
}

Random CSS not working in Heroku deployment

I have a Rails app that I've deployed to Heroku, and a few recent changes I've made in CSS (one batch of which is some media queries) just aren't working. They are present in the CSS when I look at the page source, though.
I'm running be rake assets:precompile before I push to heroku, and my config/production file is:
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.compile = true
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.active_record.dump_schema_after_migration = false
end
Is there anything else I should be doing to ensure that my CSS is all working correctly? Could this be some kind of cache issue?
I'm new to heroku, so any and all help would be greatly appreciated!!
Try following command:
RAILS_ENV=production rake assets:precompile
and push all compressed js, css and manifest file on heroku and check it.
Try this ...........
By default Rails will not serve your assets. To enable this functionality you need to go into config/application.rb and add this line:
config.serve_static_assets = true
Alternatively you can achieve the same result by including the rails_12factor gem in your Gemfile:
gem 'rails_12factor', group: :production
This gem will configure your application to serve static assets so that you do not need to do this manually in a config file.
Hope this will work for you.

Rails adds extra <style> tags to the rendered page

My application is working perfectly in development environment, but when I switched to production environment I found that the styles look a bit different. After some tracing, I noticed that these tags:
<style type="text/css" media="screen">…</style>
<style type="text/css" media="media">…</style>
<style type="text/css" media="print">…</style>
were added to the head tag overriding my application.css styles.
Is there any way to stop these tags from being added to the rendered page?
Updtae
Gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
# gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'devise'
gem 'carrierwave'
gem 'rmagick'
gem 'mysql2'
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# To include font-awesome icons
# gem 'twitter-bootstrap-rails'
# gem 'bootstrap-sass'
gem 'font-awesome-rails'
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
gem 'unicorn'
# Use Capistrano for deployment
gem 'capistrano', '~> 3.1.0'
# rails specific capistrano funcitons
gem 'capistrano-rails', '~> 1.1.0'
# integrate bundler with capistrano
gem 'capistrano-bundler'
# if you are using RBENV
gem 'capistrano-rbenv', "~> 2.0"
gem 'capistrano-rvm'
group :development, :test do
# Call 'byebug' anywhere in the code to stop
# execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application
# running in the background.Read more: https://github.com/rails/spring
gem 'spring', '~> 1.3.4'
end
group :production do
gem 'rails_12factor'
end
production.rb
Rails.application.configure do
config.cache_classes = true
config.eager_load = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
config.assets.js_compressor = :uglifier
config.assets.compile = false
config.assets.digest = true
config.log_level = :debug
config.i18n.fallbacks = true
config.active_support.deprecation = :notify
config.log_formatter = ::Logger::Formatter.new
config.assets.compile = true
config.assets.precompile = ['*.js', '*.css', '*.css.erb']
config.active_record.dump_schema_after_migration = false
end
Changing the default order in the head tag inside app/views/layouts/application.html.erb from
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= favicon_link_tag 'favicon.ico' %>
<%= csrf_meta_tags %>
to
<%= javascript_include_tag 'application', 'data-turbolinks-track' => true %>
<%= favicon_link_tag 'favicon.ico' %>
<%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track' => true %>
<%= csrf_meta_tags %>
solved the problem and no extra style tags were added to the rendered page.

rails 4 asset pipeline production fingerprint

i have an asset pipeline problem in rails 4.
i have a directory in testapp/public/assets/ which has all hashed or fingerprinted css and javascripts bootstrap.min-58853fb115aba672ce98597de33da61b.js OR animate-d81627498b7ff4acf1a1964da02db789.css however in browser i see not hashed css and javascripts like <link rel="stylesheet" media="all" href="/stylesheets/bootstrap.min.css">
i need to request the hashed files in my public/assets/
i have landing controller and one method
views/landing/one.html.erb
<%= render "shared/headmeta" %>
<%= render "shared/headcss"%>
<%= render "shared/headscript"%>
<%= render "shared/header"%>
<h1>Landing#one</h1>
<p>Find me in app/views/landing/new.html.erb</p>
<%= render "shared/footer"%>
<%= render "shared/jscript"%
>
css manifest in landing.scss
/* ...
*= require animate
*= require bootstrap.min
*= require default
*= require style
*= require overwrite
*/
headcss partial is :
<!-- Bootstrap core CSS -->
<%= stylesheet_link_tag "bootstrap.min", media: "all", "data-turbolinks-track" => true %>
<!-- Overwrite bootstrap style -->
<%= stylesheet_link_tag "overwrite", media: "all","data-turbolinks-track" => true %>
<!-- Animate css -->
<%= stylesheet_link_tag "animate", media: "all","data-turbolinks-track" => true %>
<!-- Heading font -->
<%= stylesheet_link_tag "stylesheet", media: "all","data-turbolinks-track" => true %>
<!-- General font -->
<%= stylesheet_link_tag "http://fonts.googleapis.com/css?family=Open+Sans", media: "all" ,"data-turbolinks-track" => true%>
<!-- Font icons -->
<%= stylesheet_link_tag "simple-line-icons", media: "all","data-turbolinks-track" => true %>
<!-- Flexslider -->
<%= stylesheet_link_tag "flexslider", media: "all","data-turbolinks-track" => true %>
<!-- Custom styles for this template -->
<%= stylesheet_link_tag "style", media: "all","data-turbolinks-track" => true %>
<!-- Theme skin -->
<%= stylesheet_link_tag "default", media: "all","data-turbolinks-track" => true %>
my gemfile
source 'https://rubygems.org'
#gem devise
gem 'devise'
#sprockets is a rack-based asset packaging system that concatenates and serves Js,coffescript,css,LESS
gem 'sprockets', '~> 2.12.3'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.2.0'
# Use sqlite3 as the database for Active Record
gem 'sqlite3'
# Use SCSS for stylesheets
gem 'sass-rails', '~> 5.0'
# Use Uglifier as compressor for JavaScript assets
gem 'uglifier', '>= 1.3.0'
# Use yui as compressor for JavaScript assets
gem 'yui-compressor', '~> 0.12.0'
# Use CoffeeScript for .coffee assets and views
gem 'coffee-rails', '~> 4.1.0'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
gem 'therubyracer', platforms: :ruby
# Use jquery as the JavaScript library
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.0'
# bundle exec rake doc:rails generates the API under doc/api.
gem 'sdoc', '~> 0.4.0', group: :doc
# Use ActiveModel has_secure_password
# gem 'bcrypt', '~> 3.1.7'
# Use Unicorn as the app server
# gem 'unicorn'
# Use Capistrano for deployment
# gem 'capistrano-rails', group: :development
group :development, :test do
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
gem 'byebug'
# Access an IRB console on exception pages or by using <%= console %> in views
gem 'web-console', '~> 2.0'
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
gem 'spring'
end
production.rb
Rails.application.configure do
# Settings specified here will take precedence over those in config/application.rb.
# Code is not reloaded between requests.
config.cache_classes = true
# Eager load code on boot. This eager loads most of Rails and
# your application in memory, allowing both threaded web servers
# and those relying on copy on write to perform better.
# Rake tasks automatically ignore this option for performance.
config.eager_load = true
# Full error reports are disabled and caching is turned on.
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Enable Rack::Cache to put a simple HTTP cache in front of your application
# Add `rack-cache` to your Gemfile before enabling this.
# For large-scale production use, consider using a caching reverse proxy like
# NGINX, varnish or squid.
# config.action_dispatch.rack_cache = true
# Disable serving static files from the `/public` folder by default since
# Apache or NGINX already handles this.
config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
# Compress JavaScripts and CSS.
config.assets.js_compressor = :uglifier
config.assets.css_compressor = :yui
# Do not fallback to assets pipeline if a precompiled asset is missed.
config.assets.compile = true
# Asset digests allow you to set far-future HTTP expiration dates on all assets,
# yet still be able to expire them through the digest params.
config.assets.digest = true
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
# Specifies the header that your server uses for sending files.
# config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
# config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
# config.force_ssl = true
# Use the lowest log level to ensure availability of diagnostic information
# when problems arise.
config.log_level = :debug
# Prepend all log lines with the following tags.
# config.log_tags = [ :subdomain, :uuid ]
# Use a different logger for distributed setups.
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
# Use a different cache store in production.
# config.cache_store = :mem_cache_store
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
# config.action_controller.asset_host = 'http://assets.example.com'
# Ignore bad email addresses and do not raise email delivery errors.
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
# config.action_mailer.raise_delivery_errors = false
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
# the I18n.default_locale when a translation cannot be found).
config.i18n.fallbacks = true
# Send deprecation notices to registered listeners.
config.active_support.deprecation = :notify
# Use default logging formatter so that PID and timestamp are not suppressed.
config.log_formatter = ::Logger::Formatter.new
# Do not dump schema after migrations.
config.active_record.dump_schema_after_migration = false
end
config/application.rb
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require "sprockets/railtie"
# Require the gems listed in Gemfile, including any gems
# you've limited to :test, :development, or :production.
Bundler.require(*Rails.groups)
module Marketpersona
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
# config.i18n.default_locale = :de
# Do not swallow errors in after_commit/after_rollback callbacks.
config.active_record.raise_in_transactional_callbacks = true
config.assets.enabled = true
end
end
config/initializers/assets.rb
# Be sure to restart your server when you modify this file.
# Version of your assets, change this if you want to expire all your assets.
Rails.application.config.assets.version = '1.0'
# Add additional assets to the asset load path
# Rails.application.config.assets.paths << Emoji.images_path
Rails.application.config.assets.compress = true
# Precompile additional assets.
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added
#Rails.application.config.assets.precompile << Proc.new do |path|
# if path =~ /\.(css|js)\z/
# full_path = Rails.application.assets.resolve(path).to_path
# app_assets_path = Rails.root.join('app', 'assets').to_path
#if full_path.starts_with? app_assets_path
#Rails. logger.info "including asset: " + full_path
#true
#else
# Rails.logger.info "excluding asset: " + full_path
# false
#end
#else
# false
#end
#end
Rails.application.config.assets.precompile = ['*.js', '*.css', '*.css.erb']
public/assets output of some files
/public/assets# ls
animate-d2e7ae01911a05d8ce767b98def4ae3a.css jquery.smooth-scroll-5f54331165eef2a11b63f6d615d4556e.js.gz
animate-d2e7ae01911a05d8ce767b98def4ae3a.css.gz jquery.ui.totop-d23c655a6d2cb2716708132fbd150f5e.js
animate-d81627498b7ff4acf1a1964da02db789.css jquery.ui.totop-d23c655a6d2cb2716708132fbd150f5e.js.gz
animate-d81627498b7ff4acf1a1964da02db789.css.gz jquery.ui.totop-d5647d1f3ae94dc679d5767720d0ab73.js
application-88198fbec2cb093a4a5545b36197d203.js jquery.ui.totop-d5647d1f3ae94dc679d5767720d0ab73.js.gz
application-88198fbec2cb093a4a5545b36197d203.js.gz jquery_ujs-0b8f09cf5aec4ba1be1abd9f915c77e2.js
application-9ebac1bd19f3ba981afd79fd2c5f2037.css jquery_ujs-0b8f09cf5aec4ba1be1abd9f915c77e2.js.gz
application-9ebac1bd19f3ba981afd79fd2c5f2037.css.gz landing-307af29ac27a030829bb53a3718d3987.js
application-a6b3011ab79b9f60d493732939ce4f50.css landing-307af29ac27a030829bb53a3718d3987.js.gz
application-a6b3011ab79b9f60d493732939ce4f50.css.gz landing-7c3fe69fe5644297d4d87fdcc4b915d4.css
application-aceb45182f1f0486e0e79c02dea65c4e.css landing-7c3fe69fe5644297d4d87fdcc4b915d4.css.gz
application-aceb45182f1f0486e0e79c02dea65c4e.css.gz landing-8f6eecd1178ef85964369ec66d33c4f1.js
application-d012cec9935d5b05e1b812ccc6f3cf6d.css landing-8f6eecd1178ef85964369ec66d33c4f1.js.gz
application-d012cec9935d5b05e1b812ccc6f3cf6d.css.gz landing-9b1e28a2786f16d823f619cdc65d8a40.css
application-e038cd04ae9494b6950481cfc5d4d749.css landing-9b1e28a2786f16d823f619cdc65d8a40.css.gz
application-e038cd04ae9494b6950481cfc5d4d749.css.gz landing-a7374c322246655f8a4a6d05689e50ae.css
application-e1d3507ada82fdd954d492f952b28619.js landing-a7374c322246655f8a4a6d05689e50ae.css.gz
application-e1d3507ada82fdd954d492f952b28619.js.gz landing-d728d395d4bd4966f84f4acdd1d6691c.css
bootstrap.min-58853fb115aba672ce98597de33da61b.js landing-d728d395d4bd4966f84f4acdd1d6691c.css.gz
You have 9 stylesheets you are including in one page/app? Why not compile them into one using a manifest?
I really am not sure what is going on here... So you are not getting the compiled files in your production environment?
I may be misreading your question, but are you creating your own css manifest files other than application.css, for example assets/stylesheets/shared/? Then in your production.rb (environment) file you need to tell Rails to compile them:
AppName::Application.configure do
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
config.assets.precompile += ['shared/filename.css', 'shared2/filename2.css']
end
Run RAILS_ENV=production bundle exec rake assets:precompile then add, commit and deploy your changes to production.

Rails 4 Database cleaner

I'm trying to complete some tests for a rails 4 app and I keep encountering an issue with database_cleaner.
The issue is the database is not being cleaned and warnings keep raising:
DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
.FFFFDEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.WARNING: there is already a transaction in progress
DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
.DEPRECATION WARNING: #increment_open_transactions is deprecated and has no effect. (called from block (3 levels) in <top (required)> at /Users/davidhahn/Dev/cta-projects/user-management2/spec/spec_helper.rb:49)
WARNING: there is already a transaction in progress
WARNING: there is already a transaction in progress
The configuration I have setup in the spec helper is:
require 'rubygems'
require 'spork'
#uncomment the following line to use spork with the debugger
#require 'spork/ext/ruby-debug'
Spork.prefork do
# Loading more in this block will cause your tests to run faster. However,
# if you change any configuration or code from libraries loaded here, you'll
# need to restart spork for it take effect.
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
# require 'rspec/rails'
require 'rspec/autorun'
require 'capybara/rspec'
require 'database_cleaner'
# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}
RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr
config.mock_with :rspec
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
config.filter_run focus: true
config.run_all_when_everything_filtered = true
# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
# config.use_transactional_fixtures = false
config.before :each do
if Capybara.current_driver == :rack_test
DatabaseCleaner.strategy = :transaction
else
DatabaseCleaner.strategy = :truncation
end
DatabaseCleaner.start
end
config.after do
DatabaseCleaner.clean
end
# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
# config.infer_base_class_for_anonymous_controllers = false
# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end
end
And finally here is my gemfile
source 'https://rubygems.org'
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '4.0.0.beta1'
gem 'pg'
gem 'haml-rails', '~> 0.4'
gem 'twitter-bootstrap-rails', '~> 2.2.0'
gem 'annotate', '~> 2.5.0'
group :test do
gem 'rspec', '~> 2.13.0'
gem 'rspec-rails', '~> 2.13.0'
gem 'guard-rspec', '~> 1.2.1'
gem 'guard-spork', '~> 1.4.2'
gem 'capybara', '~> 2.0.2'
gem 'spork', '~> 0.9.2'
gem 'factory_girl_rails', '~> 4.1.0'
gem 'shoulda-matchers', '~> 1.4.2'
gem 'database_cleaner', '~> 0.9.1'
gem 'launchy', '~> 2.2.0'
gem 'rb-fsevent', '~> 0.9.2'
gem 'growl', '~> 1.0.3'
end
group :development do
gem 'better_errors' ,'~> 0.6.0'
gem 'binding_of_caller', '~> 0.7.1'
end
# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 4.0.0.beta1'
gem 'coffee-rails', '~> 4.0.0.beta1'
# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', platforms: :ruby
gem 'uglifier', '>= 1.0.3'
end
gem 'jquery-rails'
# Turbolinks makes following links in your web application faster. Read more: https://github.com/rails/turbolinks
gem 'turbolinks'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 1.0.1'
Any help on this issue would be really helpful. Thank you!
It looks like this is fixed by the 1.0.0 RC1 release of database_cleaner. Try this in your Gemfile:
gem "database_cleaner", '1.0.0.RC1'

Resources