I'm new to coding and to Rails and I've run into this issue for the first time - the local development version of my app is differing in a detrimental way from the production version.
I'm using Zurb Foundation on my Rails app and deploying to Heroku to see it in production.The issue that I am facing is that locally, the CSS I wrote to get the padding between the navbar and the rest of the page is working correctly, but when I deploy to Heroku the CSS is not rendering correctly and the padding is missing.
I wrapped the yield in application.html.erb with a div of a class I named "fixednavbar" and wrote the following css:
.fixednavbar {
padding-top: 60px;
}
I put this css in a layouts.css.scss file in the asset pipeline (Rails 3.2.13). The code in the application.html.erb file is as follows:
<div class="row fixednavbar">
<%= yield %>
</div>
I have checked the code locally and on github to make sure they match up and they do. I took a drastic step and started a new repository, then removed the local git repository and started a new one and pushed all the current files there (I created a new repository on github so that all of my previous versions are still in the original repository).
After doing this, I created a new Heroku app and deployed and still the production version is not rendering the CSS the same as the development version.
I'm at a complete loss as to why these versions would differ when the code is the same (unless there is something lurking somewhere else that I have not thought to check).
Any and all help is much appreciated. As I said, I'm knew to Rails (and coding for the most part) and this is the first time I've run into an issue like this.
Thank you!
Update:
I have continued to try to sort this out. I did other work on the application and then came back to this issue. I want to get the production version to reflect what is in development, so any help at all would be amazing.
To describe the issue further: It is almost as if my production deployment to Heroku is stuck in an old version of the app when the css wasn't worked out yet. The navbar color is stuck on the first color I changed it to and will not update to the new color. The sticky nav is still causing an issue in production where the body is partially hidden behind the nav.
Now, in development running the local server, I have fixed all these issues. The changes are reflected in development and everything is as it is intended to be.
After the changes, I commit to the git, then I push to github. After pushing to github, I push to Heroku.
The github files reflect the changes and the code is as it should be. Still, Heroku is not reflecting this.. I'm honestly stumped here and need some help please.
With some help from the users who responded, I was able to identify the error and search for the solution. I found it HERE.
The solution is to look in the production.rb file and find the line where it says
config.assets.compile = false
and change "false" to true.
config.assets.compile = true
Then run
rake assets:precompile RAILS_ENV='production'
After deploying to Heroku, you may need to run
heroku run rake db:migrate
This got everything working correctly upon deployment to Heroku.
How have you included this plugin? Instead of adding the js and css directly, try using their gem from https://github.com/zurb/foundation-rails and remove any direct references from your app. I've faced similar issues with other plugins like bootstrap, bxslider etc.
As a beginner, I was having a difficult time with the same issue. Because I'm using Rails 4, the simple step of removing this line from config/application.rb did the trick.
config.assets.initialize_on_precompile = false
https://devcenter.heroku.com/articles/rails-asset-pipeline
Granted, I troubleshot all the above steps and a few others from other postings.
Related
Update 2:
This probably has to do with the this PR where assets have been removed as dependency.
Update 1:
Managed to get a reverse shell into the serverless function and it really would appear that there is no public folder anymore:
Provide environment information
"next": "12.2.5", // Also tested on 12.2.6-canary.7 and 12.1.6
"next-i18next": "12.0.0", // Also tested on 10.5.0
"react": "18.2.0", // Also tested on 17.0.2
"react-dom": "18.2.0" // Also tested on 17.0.2
How are you deploying your application?
Vercel
Bug Description
Context
We encountered a bug around next-i18next that resulted in serverless crashes for catch-all routes. We noticed this bug for the first time Monday around 14:00 CET and think it is potentially related with a change in the serverless runtime/filestructure as older deployments that used to work stoped working when redeploying.
Some other people also seemed to have encountered the same bug. See also here:
This discod thread
This next-i18next bug report
Stackoverflow same problem
What we tried
So we upgraded our versions of next and next-i18next (like some of the other people did).
With the most recent next.js and next-i18next versions translations seem to work only in very specific cases.
We created a minimal replicable deployment (Repo) where we prebuild two pages via putting them in getStaticPaths:
https://ed-i18n-bug.vercel.app/en/test/prebuild
https://ed-i18n-bug.vercel.app/de/test/prebuild
Both pages do not use translations when opening them directly.
However, when first navigating to the index.js and then clicking on of the links the two pages use proper translation.
Note: The translations will break upon refresh.
Setup Description
catch all route in pages folder
page set to static site generation
default locale is set
incremental static regeneration is on
Expected Behavior
working Translations
Links to Reproduce
Example repo here: https://github.com/everdropde/ed-i18n-bug
Example Vercel Deployment: https://ed-i18n-bug.vercel.app/de
Steps To Reproduce
Clone the Repo and deploy it to Vercel
Click any link on page
if you have outputFileTracing enabled and using latest version of Next.js then this should work with latest CLI version
https://github.com/vercel/next.js/issues/40130
Setting env variable VERCEL_CLI_VERSION=vercel#28.1.4 fix the issue
Also if you set outputFileTracing: true in next.config.js it works with latest CLI version
I recently changed an image on the landing page of my herokuapp built in rails. I realized that everything worked fine except that the landing page threw a 500 error. Upon some research I realized i should run RAILS_ENV=production bundle exec rake assets:precompile
After doing so, the images and some of the styling came back but some of it is still screwy and I cannot understand why.
I've read through just about every stackoverflow thread, the rails guide on the asset pipeline, and others but I can't get it to work. I've amended the files that need amending
as far as I know but nothing is working to make the styling revert to how it should be.
However, on the rails guide it notes that there are two caveats to locally precompile:
You must not run the Capistrano deployment task that precompiles
assets. You must change the following two application configuration
settings. In config/environments/development.rb, place the following
line:
config.assets.prefix = "/dev-assets"
I did the change within development.rb but I am not sure on how I can not run Capistrano. I dont think I'm doing that so maybe it's throwing some things off - idk, but each time I try to recompile now, the rake aborts. Any help is very much appreciated.
I seem to be having major issues with the asset pipeline in Rails 3.2. It alls started because I wanted to add a single, simple style to my application.css.scss whilst working in the development environment. I have done this in the past with no problem and it just works because there is no caching occurring (as you would expect).
However, when I attempted to add the new style today, Rails refused to load the updated styles. I checked my environment settings and they all seem correct in development.rb,
config.assets.compress = false
config.assets.debug = true
I did some research and came across rails 3.1 asset pipeline css caching in development. Following the advice given in that question, I made sure that I deleted the tmp/cache folder as well performed a clean using rake assets:clean just in case I had run the app in production mode at some point and it needed cleaning up.
After all this, still no luck. Just to confirm that I hadn't made a bonehead mistake, I temporarily moved the style to another stylesheet. No problems! It worked perfectly! So I moved the style back and it won't load again.
I also checked the console. It reloaded the other stylesheet correctly but no mention of the original stylesheet.
Now, here comes the major issue. As a last ditch effort, I tried clearing my browser cache. I normally have no problems with it on but I thought something might be cached and causing problems. I cleared it and reloaded the app and.... no styles loaded whatsoever!
It seems that all of my application.css.scss styles were cached at some previous point and now I simply can't reload them!
UPDATE:
Although I still haven't fixed the problem, I've worked around it by creating a new stylesheet called main.css.scss (name not important) and moving all of the styles to the new stylesheet. This works because of the //= require_tree . directive in the manifest.
But if anyone can shed some light on why the original stylesheet stopped working, I would love to know!
try rm -r public/assets/*
maybe your assets:clean task is not working properly.
This is an app that I am upgrading to Rails 3.1, along with the asset pipeline. Everything looks peachy in development, but when I push to heroku, the images in my css are not displaying.
Couple of questions. First, should I leave these files with the css extention, or should they be renamed to either scss, or css.scss.erb?
The other question I have is how should I reference images in the css. Currently I have...
background: #B4F4FF url(/assets/img01.jpg) repeat-x left top;^M
I am pretty sure I need to replace url with either 'image_tag' or 'asset_tag'...looks like there are a few options available. Also, what should the path be?...../assets, assets/images, just the file name???
I've tried all manner of methods, and paths, and can't get this to work in Heroku. Any help appreciated!
Wow! This was a real pain to figure out.
For me the issue centered around static pages that I had in my app. I had to add the line...
config.assets.precompile += ['static_pages.css']
to config/environments/production.rb, then compile my assets locally with
RAILS_ENV=production bundle exec rake assets:precompile
then push all that to heroku.
I was running into issues with Heroku showing my 'places.js' was not precompiled, even though im running on the cedar stack, and during the slug compilation it is running the rake precompile task. so i tried running it locally with rake assets:precompile RAILS_ENV=production and indeed rails was not precompiling my /app/assets/javascripts/places.js.coffee.erb asset.
my production.rb is using default rails 3.1 configuration, and i even tried removing the .erb from the asset, but to no avail.
I also thought since my places.js.coffee.erb asset is NOT included in the sprockets manifest (i include it manually in my app), perhaps it only precompiles assets in the manifest. Requiring it in the manifest didn't work either.
only my application.js.coffee and `application.css are precompiling (with and without a digest).
the only issue i found was possibly poor regex being used to match assets, but the default of (?:\/|\\|\A)application\.(css|js)$ does not match my asset, so it should be included.
i am not sure how to troubleshoot from here. everything is pretty much default. any thoughts on what could be happening here?
Firstly, if you want a file to compile when it is not in a manifest, you need to add it to the precompile config option:
config.assets.precompile += ['places.js']
Secondly, can you edit your question to include your manifest - it may be a syntax issue. I will edit this answer if I can see what the issue might be.
I had the same issue and resolved it like this:
# add new file /app/assets/javascripts/places_manifest.js
//= require places
# add a line to config/application.rb
config.assets.precompile += ['places_manifest.js']
# in your views include places_manifest, not places
javascript_include_tag 'places_manifest'
While the above solutions seem fine, I wondered why do I have to do this?
Like everyone else, I got the error in production stating that my newly added javascript file was not pre-compiled. It was however, I found it's code in the minified application.css file that Rails had generated on my production server.
The problem was that while developing, I thought I would need to add a javascript_include_tag helper to load my new javascript file. Adding that helper was the source of my particular error. I just removed it, and everything worked fine in both development and production environments.
So my suggestion to you is look for signs of your new .js file in your minified application.js and don't modify any other files as the above solutions suggest. Please point out the error in my ways if necessary ;)