I am working on a web application and using Symfony2 for the first time.
I have this problem: I have a template which references a stylesheet. Now, when I make changes to the stylesheet (e.g. change font colours), they are not reflected on the page when I open the page in my browser. It keeps on using the values of the original stylesheet as though it was never changed (in fact, I even removed the stylesheet completely, still the page displays the values of the original stylesheet).
Here is the code in the template:
I have already tried clearing the cache and running Assetic:dump with no success. Any help will be greatly appreciated!
p.s. I am working in the dev environment
By default, symfony will make an hard copy of your assets in the web directory. If you want to have your changes reflected automatically, you need to make a symlink instead of an hard copy.
You can use this command:
php app/console assets:install --symlink
Related
I am working on rails app and now I am having trouble.
Early when I use to change my frontend styling and apply changes in css then they quickly show up on reload in brower.
But in present, don't know but something went wrong. Whenever I change css and save it then onload, things remain same.
After debugging, I found that app is picking styling files from precompiled assets pipeline. So for the solution, I have to recompile the assets then 2 new files are generated against wach file changed. And there will be 4 files in total against a single css file in which changes are made. So now I have to delete old ones and then have to restart the serve and refreshing the browser will show all the changing and that is weird as I have to do it all the time for every single change.
I can't figure as I am new to rails. Help....
Please clear the tmp cache first and then run the server
$ rake tmp:cache:clear && rails server
If you are developing the app, you should delete public/assets directory. Then restart the app. Don't run asssts:precompile task. Your most recent changes of assets will be up to date without restart the app.
I had the same issue and found a solution : run rake assets:clobber, it will remove the precompiled css and js. Then run yarn build --watch to build back the css and js file.
Dont run the assets:build as the same issue will revert.
This might actually be a browser issue, where the browser is caching the previous CSS and not reloading your new CSS changes.
Instead of reloading the page with CTRL+R, try reloading the page with CTRL+SHIFT+R
This will force a reload of the web page and clear the page cache, which forces all the assets to reload and fixed the problem for me.
No need to run css:clobber, assets:precompile, or anything like that! Just change the way you reload your browser :)
So I have find out the reason and it was because I have run the command of assets precompile which I shouldn't have to run as rails was doing it already for me may be due to configuration of my project or may it is its default behavior.
To solve this problem I have to delete my projects folder from my system and clone it again and things got normal again.
And now I never ever going to run assets precompile command again 😂
I am working on SuiteCRM, and i want to change the CSS of my website in order to personalize it but there is an issue.
When i am changing the "style.css" of the SuiteP Theme, the pages aren't changing at all. Here is my question:
Does someone know how to change the css of this CRM and can help me to fix it ?
Thanks a lot
Make sure that your active theme is "SuiteP".
You need to know that SuiteCRM store things inside "cache" folder and you are doing changes without refreshing cache files. Cache files location will be cache/themes/SuiteP/css/style.css. So for quick changes, you can use browser developer tools.
Moreover, if you change core style.css then empty cache directory and (hard)refresh your browser. If cache files don't exist then Suite will build new using core file.
Like Star previously mentioned, Suite does cache the CSS.
Though, if you're not updating the SASS file, and just updating the CSS directly, your changes will be temporary for when the CRM next re-builds the CSS (I believe this is part of the Repair and Rebuild process in the admin section), your changes will be lost as the CSS file constructed from the style.scss file.
I'd recommend installing sass (via a gem or other means, however you choose), making changes to the scss then recompiling the css (or watching for changes if working locally, which I hope you are for working with Suite) when you've applied your changes.
If you still don't experience changes, try a repair and re-build or delete the cache directory and let it recompile on the next page load.
there are 2 options:
change core file and then delete cache contents. Refresh your page twice.
made changes in cache file. Make sure developer mood is off. Once you are done then copy it core file.
Create a new subfolder CUSTOM, copy the CSS files that are under suiteP (or the current theme) into the new custom. copy the whole path with folders, even if the folders are empty.
So the new path for the sytle.css with be /costum/theme/....../css/sytle.css
Change the file under the custom folder. The previous answers are not correct. This is well documented under the suite CRM docs.
Sometimes it doesn't work. Try next steps:
SuiteCRM better to use in development mode.
Not always the cache files deleting works for me. Better to use the tool in Admin panel - Quick Repair.
Sometimes good to clear browser cache (in dev mode reload a page by right clicking the refresh button).
This problem is driving me crazy... I think I've tried every conceivable combination of Sass file, ERB file, asset helper, image helper, etc. etc. Someone please give me new ideas!
Context:
Rails apps require use of asset helpers so that when the assets are precompiled, the source will be a fingerprinted asset file. I.e., if you just called img src="X.jpg", the site in production would look for X.jpg, but the file in public/assets has actually been fingerprinted as X-as;diofua;wemfiwaejfoiawefo.jpg. The only way to get to that fingerprinted file is to use an asset helper, e.g., image_url ('X.jpg').
Right now in my live site, I'm using an asset helper, but for whatever reason, it's not pointing at the fingerprinted asset. Note that the assets are found in development (but again, that's because there's no fingerprint added in development).
Code
Image titled "classic-map.png", located in app/assets/images/galleria
Image is called from a css.erb file required in the application.css file. In the css.erb file, I have the following code:
background-image: url(<%= asset_path 'galleria/classic-map.png' %>);
For reference, http://guides.rubyonrails.org/asset_pipeline.html
Note that I'm choosing to write this as a css.erb file, hence the use of asset_path vs. asset-path. Also, I initially thought that the issue might have been in interpolation, but in the page source, the url is definitely working, it's just that it's pointing at url(galleria/classic-map.png) instead of url(galleria/classic-map-apsoidufalskjf;kasj.png)
A million kudos to whoever can help!
For what it's worth, this happened to be AGAIN, and this time I could not use the hack because I desperately needed the fingerprint. So somehow, magically, I ran a rake assets:clobber and heroku run rake assets:clobber to clean all assets, and then a straight up git push to force Heroku to do the precompilation for me. That did it, and everything works.
Now, when this happens, I clobber assets locally & in production and push, forcing Heroku to precompile remotely. Similar to #user2880239's answer. I have stopped precompiling locally and checking into git.
I sat with a Sr Rails developer who still couldn't help me fix this. But the workaround we ended up using was that we just manually removed the asset fingerprint in the public folder (since the fingerpoint is what the asset helper is meant to point to).
I.e., the file galleria/classic-map-587854758918434124.png we just manually changed back to galleria/classic-map.png and it works fine.
Note that if you do this 'hack', the next time you precompile assets, Rails will create another fingerprinted asset, so you'll have duplication unless you want to keep deleting the additional fingerprinted asset each time. For me, I don't care about the duplication, I care about not thinking about this anymore.
Did you check RAILS_ENV ?
bundle exec rake assets:precompile RAILS_ENV=production
I had the same problem you did. This blog post helped me.
What I did was change a few things in my config/environments/production.rb file, namely...
config.serve_static_assets = true
config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’
config.assets.compile = true
Note that you might not need to 'add' any of those properties since they may be pre-set to false or merely commented out.
Then I did the heroku dance:
rake assets:precompile
git add .
git commit -m "Fix static assets"
git push
git push heroku
I'm having the same issue. I even tried the helper from the rails console from heroku, and the helper works fine there!!
$ heroku run rails console
Running `rails console` attached to terminal... up, run.8071
Loading production environment (Rails 4.1.7)
irb(main):001:0> puts helper.image_path("bg.jpg")
/assets/bg-00acfb7dbe138102509d82ac2313c24d.jpg
My final "solution" was to update config.assets.compile = true in config/environments/production.rb to fallback to the non fingerprinted image.
Hope this solution could help to someone. And if you had any real solution, please make me know!
The answer to this for Heroku is in their Pipeline docs here.
By doing clobber you are basically cache-busting all your assets and forcing all clients to reload all static assets (even if they have not changed) every time you deploy your code. That is not advisable as it means every time you deploy ALL clients will experience slow loading times until all assets get cached again.
Your css file has a dependency to your image file, so you need to tell the assets pipeline about this by putting this at the top of your css:
//= depend_on_asset "galleria/classic-map.png"
This tells sprockets that if class-map.png gets a new fingerprint then the css must also get a new fingerprint. So it will only recompile the files (and dependencies that changed).
Also for others landing here, be aware that if you are using asset_path from ANYWHERE other than a view (eg in a model) you need to prepend the full context:
ActionController::Base.helpers.asset_path('your-image.png')
More info here.
For some reason, unknown to me, I am forced to precompile my assets when I deploy to Heroku. After I locally precompile and deploy, I obviously go back to changing my site. I have come across a problem where Rails "remembers" css rules that I have precompiled when I try to change them in my app/assets folder. I thought this might be because there is a new assets folder in public/assets and these styles might take precedence. I removed this folder and the problem still persisted. I can add css styles but I can not delete/overide css styles that had been previously precompiled. I searched these forums further and found CSS assets simply stopped to reflect any change. I tried it. However it has not fixed the problem. The only time I can get my css changes to apply is after I first change the style in my app/assets folder, then I precompile my assets locally, then only after I push to git AND deploy to Heroku will my changes reflect locally.
I would post code but I'm not sure what code would be relevant. Since what I'm talking about is a simple "border: 1px solid black;" style.
I think it is worth mentioning that after I deploy to heroku everything always works as intended.
Thank you for any help you might be able to give me.
Clean out your assets before you precompile anew:
rake assets:clean
otherwise your local machine may use the existing precompiled assets, rather than the new (changed) assets.
I designing an programming a website using Symfony2. I completed some parts and checked the client side in both dev and prod environment. In the first time everything was fine and I saw same result in both environments, But after sum changes in views (I'm using Twig with Three-level Inheritance) such as adding sum other stylesheets in "stylesheets" block, dev environment works fine but in prod environment no stylesheets added and its using old data. I cleared cache and log manually from both path "app/cache/dev" and "app/cache/prod" ... but nothing changed. I removed all stylesheets in block and cleared chache again old data is still there!
Any suggestion?
Apart from clearing the cache, make sure you publish your assets:
app/console assets:install --symlink web
app/console assetic:dump
The problem was about removing cache files. I had been removing cache files via cPanel filemanager. It gave "all files removed successfully" but they didn't. So I found another way to clear cache. I used shell_exec:
shell_exec('rm -r app/cache/prod');