Pushed to Heroku - Assets(+?) Missing (Rails 5) - ruby-on-rails

I pushed a sample app I was working on to Heroku. Rails 5 - I now notice a lot of issues/differences, a lot I can relate back to an obvious pipeline issue. Majority of the references I see are from R3/R4 but mention putting
config.assets.compile = true
config.assets.digest = true
in and modifying all url to font-url or image-url - I did that for majority of the fonts, but I'm still seeing blank images, and broken links/missing icons.
Another weird thing is I used JSON Builder to builds out a site.json page - The page itself is actually fine; No issues. However, when I try to limit it with a parameter it immediately returns a 500 error. I've found 4-5 other posts on SO about this, each with a minor amount of replies, and usually they say to do what I mentioned above.
I even tried to go into all of my CSS files cores, and change it to
font-url('<%= asset_path("mana.eot?#iefix&v=1.3.0") %>') which also didn't do anything.
I read on Heroku's help site that it has issues due to the MD5 fingerprint and I followed through the steps to connect to the bash to see the file's existance AND the name, but I'm unsure how to really.... do anything about that? Don't they have the same fingerprint when locally compiled/C9/IDE?

In terms of photos missing, you probably have to upload them to AWS or something similar and save the information there. Make an account and follow the instructions, it is pretty straight forward. I had the same problem for my app and that was the solution for me.
In terms of links make sure none of them are localhost:3000 because that will break the links.

Related

See an empty page when access `/rails/mailers` in production

I am using rails 5 and wanted to see the /rails/mailers url in production mode under the authentication.
I am able to implement authentication under the URLs but I can only see a blank page on production(Heroku, review app) but on local I can see the complete page without any issues.
I tried production mode on local as well and that was also working fine.
Running out of ideas in that direction. Thanks in advance.
I got to know,
We are not pushing the spec directory to Heroku, hence there is an empty list of the previews and not able to view any preview at all.
If you use Heroku beware of your .slugignore, you might have 'spec/' in it.
If it is the case, as spec/mailers/previews doesn't exist on heroku instance, you've got a blank page as a result (status 200).
Also note that unlike .gitignore, .slugignore does not support negated ! patterns.
Here is my workaround :
1.move previews away from spec/, to app/mailers/
2.
#environment.rb
...
Rails.application.configure do
config.action_mailer.preview_path = "#{Rails.root}/app/mailers/previews"
end

Favicon and headers not working in custom domain for rails app with heroku and Godaddy

I have a rails app hosted on heroku and then pointing my custom domain to it via GoDaddy.
I've been struggling to get the favicon to work and have tried everything in this post. Favicon shows up on rails local, not on hosted app
I've also tried rake assets:clobber
I've also tried deleting the favicon, recompiling it, and then pushing. None of this has worked.
Before this I was getting an error about X-frames being from SAMEORIGIN that was causing my site to not render anything in the head as well as not load.
So I added this line to my application controller per another stack overlow answer
before_filter :allow_iframe_requests
def allow_iframe_requests
response.headers.delete('X-Frame-Options')
end
I'm not sure if this is related or not but somehow everthing works on myapp.herokuapp.com but nothing is getting loaded in the head or source in inspector on myapp.com
Here's what it looks like.
As you can see.. nothing is really showing up in the head.
On myapp.herokuapp.com you can see everything that is supposed to be in the head show up.
I'd really like to understand what's going on as this has been super frustrating. I have tried many solutions that I found here but have yet to have anything work. My hypothesis is that it's something to do with Godaddy. Yes I have cleared my cache multiple times.
Thank you for your help!
Perhaps try my site to generate favicons and the correct markup for them:
https://favicongenerator.co
You can upload an icon and it generates all the sizes and the correct markup for rails.

Reverse Proxy with Heroku (for Wordpress) won't show full pages

I am trying to use a reverse proxy to serve a Wordpress blog running on EC2 at /blog from a rails app running on Heroku. I've used the rack-reverse-proxy gem and followed directions like this:
How can I use a subdirectory instead of a subdomain?
My app is running at http://myapp.com, my main target (wordpress) server is running at http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com.
The pages on the target server all serve up fine when accessed directly. However, no matter what page I try to get through the reverse proxy, the HTML gets cut off. I've tried serving via both my own custom builds of Wordpress on Ubuntu (EC2) and on hosted examples like Bluehost. I've tried to access simple, handmade HTML and text test files, as well as the php files automatically generated by wordpress. Every time, the file is cut off.
Text files just get randomly cut off after ~1000 characters (this is variable)
Ditto for hand-coded HTML files
Wordpress files seem to get cutoff during the <head> (often mid-word) and render an empty <body>.
If a page should exist (e.g. http://ec2-xx-xx-xx-xx.us-west-2.compute.amazonaws.com/test-post, it will load (at least partially) at myapp.com/blog/test-post, so I don't know that rewrites are the issue.
I've tried enough variables on the wordpress/destination server that I'm inclined to think it's something on the Rails side (I have the same issue whether running "myapp" locally or on a Heroku test server). Beyond that, I'm stuck.
Any thoughts as to what I might be doing wrong? There's nothing in the Apache logs to indicate that anything is getting cut off. I'm pounding my head over this to no avail, and would really appreciate any help.
FIXED IT!
Digging into the rack-reverse-proxy gem, I found that I'm not the only person that had an issue with this:
Seeing some issues with Content-Length being corrupted, this ensures it matches body length as delivered.
The fix hasn't been merged into the master branch, but I forked my own copy, applied the fix, and it's working great. Hopefully it'll be merged into the master and nobody else will have to worry about this.
EDIT
One more thing that might be helpful for somebody else, if they are having problems with Visual Editing Mode not working under wordpress: Make sure that you also include this update to have the headers get passed in properly. The gem just hasn't really been updated in a couple of years, so it's up to you to go through and copy in fixes from other people. Applying those two fixes has everything working fine for me with a Heroku app/AWS&Ubuntu Wordpress setup.
Heroku will cut the request after a certain amount of time which would cause the behavior that you're seeing.
You basically have to pull the page from the wordpress blog and reserve it via Rack in the time for one request - think that could be the problem?

Content of assets (images, js and css) switches randomly on different requests

My app - cloudlist (cloudli.st) - uses Heroku, rails 3.2 and a bunch of gems. For the past few days we've started seeing our layout break a few hours after a deploy.
The strange thing is that the content of a file switches randomly on different requests. We use the rails asset pipeline with all defaults, nothing changed. Right after the deploy everything is fine. After some time (usually a couple of hours) the layouts starts to break in some areas. Sometimes just one image has a different content, sometimes even JS or CSS files have different content. We've also seen files that were completely mixed up. All this is very strange and I can't find anything on the web.
To illustrate the problem see the following image which have sprites with the wrong content.
Also see the content of the file frame.png. It should show the frame for a tile but sometimes it shows the awards nominee badge.
Has anyone seen anything similar or do you know how to solve this?
If this continues we need to migrate away from Heroku and use another infrastructure.
According to the recommendation given by heroku (https://devcenter.heroku.com/articles/rack-cache-memcached-rails31) here are the results.
In short: it didn't help.
Long version:
I don't use memcached for caching. Neither I use fragment or action caching. At least I don't use caching at all in my app.
The only thing that gets cached is stuff done by the configuration parameter
config.action_controller.perform_caching = false
in production environment.
I went through the article and checked every parameter. The only one I had different was config.serve_static_assets which was false. I set this to true, redeployed (with caching turned on) and got the same issues after a couple of hours.
I don't know what's wrong but as there is content in my files which doesn't match the expected I have to conclude that this is something within your infrastructure. E.g. I request application-(any-digest).css and I get sprite-(any-digest).png or application-(any-digest).js

My Rails Application doesn't update the localized strings in production mode

I have a standard Rails application running with the I18n support. I have extensive caching running for this app. I edited a few strings and confirmed it worked locally. I also confirmed I have the right strings on the file for the live site. Still for some weird reason I do not see these changes for my live site even though I have not fragment cached anything here.
Any ideas what is going on?
Another one with the same problem as me :)
I ended up with this solution:
http://szeryf.wordpress.com/2008/02/02/multilingual-page-caching-in-ruby-on-rails/
I couldn't change the structure to include the language identifier in the URL as suggested here:
http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/341bba9357bfc608
Depending on your structure and how fare you are down development, choose either one. However, it's probably easier if you have the cache either as part of your domain or your url.
I hope multilingual caching will be improved in future rails versions.

Resources