Rails app issue with URL - ruby-on-rails

I deployed today on 2 different AWS environments (set up identically) the same version of our app.
On our second app, I have an issue when users click on a link.
Link should redirect to my_app/module#/page and instead, it redirects to my_app/module#!/#%2Fpage
Locally and on the first app, it works fine. I look and could not find the reason why encoding is changed in this instance.
They are both rails app. nginx used on both servers if that can help
Thanks.

Issue was due to Angular version on one of my apps.
After editing the package.json file and re deployed, everything is back to normal.
issue related: URL hash-bang (#!/) prefix instead of simple hash (#/) in Angular 1.6)

Related

Ruby on Rails link generated with link_to helper no longer works in Chrome

Chrome has been making a lot of changes recently, and one of them has broken a code statement I use to retrieve a document stored in a database, related to a parent record. The action to upload the file and create the attachment relationship is working, so my users can still add documents. They can no longer download and view stored document attachments. The code is using the link_to helper method, and appears to be building the link correctly, verified by the fact that it still works using Edge, so my users have an ugly workaround, but I need to understand what is happening. I have confirmed that it is indeed Chrome that is the problem, because at first I couldn't recreate the defect in development (until I updated my Chrome browser to current version.) Now I can recreate the defect in my development environment.
When the link in my form is clicked, Chrome displays an error screen with this text:
This page isn't working
(*localhost*) sent an invalid response
net::ERR_RESPONSE_HEADERS_MULTIPLE_CONTENT_DISPOSITION
If I extract the link using developer tools and try and execute it in an empty browser window, I get the same error.
The link is constructed like this:
(*name of the file attachment*)
Before you ask, yes, I have confirmed there are no commas or quotes in my file names! lol
I am hoping someone somewhere can point me to a solution, hopefully simple, maybe obvious, that I can use to get my web form to play nicely with Chrome again - application code change, web server configuration (I am running on RHEL7 Apache in production and Puma in development, my database is Oracle, and I am building with Ruby 2.3.6 and Rails 5.1.5, along with many many gems).
I hope I have covered all the relevant points. Thank you for taking the time to read this post!
Issue has been resolved by upgrading gem attach to version >= 1.0.5. Many thanks to the gem author for excellent responsiveness.

Hash slash (#/text) wipes out url leaving domain with /text

Working on some rails app where observing a weird issue, when there is a “#/whatever” at the end of a url, it wipes out the rest of the url.
For e.g., if we have below URL
https://www.example.com/sub/123/cou/321/something
and we add #/hello?how-are-you, like
https://www.example.com/sub/123/cou/321/something#/hello?how-are-you
and press enter, url changes to:
https://www.example.com/hello?how-are-you
On all environments. Tested this in other rails app and .NET apps where this is not observed, below are details of my ROR app:
rails 4.2.7.1, ruby 2.3.1 and many gems
Question:
How can I prevent this behaviour, as this send wrong url.referrer to server
You can't. Fragments are local to the web browser, that's their whole point. They never get sent to the server, so there is nothing you can do on the server to get them.

puma-dev link not working under Linux

I'm work on Linux and I develop a Ruby on Rails application.
I've set up the puma-dev seeing this page and they say, if you are working on Linux, please setup dev-tld-resolver.
I have completed both setups and I want to test if they work correctly.
I linked puma-dev to my Rails app and run it in the foreground with the -sysbind option. It runs, but if I type the URL (myapp.dev), it does not work.
How can I solve this problem?
I solved the problem myself.
The problem was Firefox. Firefox not support .dev domain so it couldn't connect to my application.
As I turn my app with Google Chrome, it executed correctly.

Rails Dynamically Switching Static Pages

I am running Rails 4 under Nginx and Phusion Passenger on my local machine to develop a web application, everything is setup and running smoothly - there were no problems.
However, when I try to view my home controllers index method, which is a .html.erb file, generated from haml via CodeKit, the page either displays nothing or the current version, and then the previous version of what I have done.
For instance:
Version 1: <h1>Hello, World</h1>
Version 2: <h1>Bye, World</h1>
If I had V1 on the sever, and update it to V2 by simply replacing the file, and refresh the page shows V2. If I refresh again it shows V1. If I refresh again it shows V2 etc…. Worse, if I manually re-type the address the page shows white, nothing, until I restart Nginx.
Is there some weird caching going on… I haven't done anything other than what is outlined in the Rails tutorial: http://guides.rubyonrails.org/getting_started.html#hello-rails-bang
I have touched files up to stage 4.3.
This is a serious problem.
It turns out rack_env was set to production, which enables config.cache_classes, resulting in weird page results and all of this mishap.
Setting rack_env development solves this issue.
Makes sense, since a deployed application won't be having pages constantly changed for .css, content or structure etc….

Heroku App with a Wordpress Blog

I recently discovered that Heroku now allows PHP which means that a wordpress blog can be hosted on it. I also found this project template: https://github.com/mhoofman/wordpress-heroku
I have a ruby on rails app which is to be hosted on heroku with a domain www.mysite.com, and in that app, i need a way for www.mysite.com/blog to show the wordpress blog.
Can someone help me out, with details on how I can do this?
Whilst I've not used the new PHP platform I don't think what you're asking for is going to be possible.
When you deploy an application to Heroku it detects the type of application during the push process and sets up the application accordingly, Heroku use Apache to host PHP as you can see from the output in this post http://tjstein.com/2011/09/running-wordpress-on-heroku-and-amazon-rds/ - there's not been any mention of mixing platforms in a single application yet so would imagine that it's not supported.
The nearest you'd get is hosting your site and your blog in two seperate applications with the blog on blog.mysite.com and then put a redirect on www.mysite.com/blog to the blog.mysite.com url.
Im Still working on this
the closest to getting a solution is using the reverse proxy gem
see the answer here:
How can I use a subdirectory instead of a subdomain?

Resources