I have created a ruby on rails application. I am having below scenario
In localhost for getting referrer link i'm using request.env["HTTP_REFERER"] it's working perfectly not giving null.
I have uploaded the code in heroku , but request.env["HTTP_REFERER"] is giving nil , i have checked in heroku logs.
Please provide a suggestion why it's giving nil ? is there any way to get referrer link other than request.env["HTTP_REFERER"] ?
request.env["HTTP_REFERER"] giving nil is acceptable when directly navigating to a page, I suggest to use link_to :back instead or specify where it should go back (link_to root_path).
Related
For some unknown reason, when I used the same URL that had worked yesterday, it won't work again today. Still not sure what is the reason.
The URL I used yesterday was (I did see tab content yesterday):
curl -silent https://www.docusign.net/restapi/v2/accounts/0000000/envelopes/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/recipients/tabs?include_tabs=true
Today, the above URL will not work any more (I won't be able to see tab content) unless I change the URL to:
curl -silent https://www.docusign.net/restapi/v2/accounts/0000000/envelopes/aaaaaaaa-aaaa-aaaa-aaaa-aaaaaaaaaaaa/recipients/1/tabs
Strange. Not sure what is changed at server.
I have tried a different user account to login, then the first URL started to work. It could be somewhere there is a setting to control restful API behavior for each user account. But I am not aware where it is.
I'm working on a facebook app where the user has to sign in (using FB) to participate.
This works fine on every browser except IE9, after the app tries to sign in, the user gets the error "this content cannot be displayed in a frame"
If I check the properties of the iframe, I can see the URL is http://myfancyapp.com/auth/facebook/callback
The signing in process seems to work since I can open the app outside the iframe and I'm successfully logged in. So the problem seems to be IE9's security policy. After some searching I figured out it needed P3P tags, so I added some in my application_controller like this:
I've also tried adding X-Frame-Options but it doesn't made a difference. What else could I try?
It turned out that Omniauth was redirecting the wrong way, it tried to put the absolute URL in the iframe. Since the absolute URL was from Facebook, it gave an error since facebook URL's are not allowed to be loaded in an iframe.
To fix this, I modified the Omniauth initializer (omniauth.rb) and specified the full host like this:
Rails.application.config.middleware.use OmniAuth::Builder do
provider :facebook, ENV['APP_ID'], ENV['APP_SECRET'], scope: 'email', full_host:ENV['FULL_HOST_URL']
end
The full host is stored in a environment var like this
FULL_HOST_URL='//myapp.provider.com'
I'm trying to get a custom 500 error page to show on Heroku, running rails 3.2.11
I've followed the steps at:
https://devcenter.heroku.com/articles/error-pages
The process worked fine for the maintenance page, but doesn't seem to work for the error page. I'm positive the S3 URL is correct in Heroku, and when I visit the S3 URL directly I can view the error page just fine (it is set to public).
config.consider_all_requests_local is set to false in production.rb
Any ideas as to why Heroku is not showing it? I just get a blank screen in various browsers (Chrome says it's a 500 error but doesn't render a page).
The heroku's custom error page isn't displayed whenever an exception occurs in your application.
Your application is responsible for displaying this kind of pages.
See using exceptions_app with rails 3.2.
The error page happens when an error occurs with heroku.
The devcenter page about error pages says, about testing your error page :
To test your error page, you can push a bad deploy such as putting a syntax error into a key configuration file, or by creating a path on your app that sleeps for 35 seconds (thereby triggering the error H12 Request Timeout.
I'm integrating capybara to a project. At first instance, I just wanted to check what is displaying the login page, so I made this code:
require 'acceptance/acceptance_helper'
feature 'Login' do
scenario 'sign in with right credentials' do
visit '/'
save_and_open_page
end
end
But when I run the test, it shows me:
Failure/Error: visit '/'
ActionController::RoutingError:
No route matches "/login"
# ./spec/acceptance/login_spec.rb:6
If I enter to the application without a valid session, it redirects me (code 302) to a rubycas server to log me in (which has the /login context at start) and after that it redirects me again to my server.
What should I do to just view the login page or how to maintain the redirection references in capybara?
I usually do this:
Inside my test.rb :
require 'casclient'
require 'casclient/frameworks/rails/filter'
CASClient::Frameworks::Rails::Filter.configure(
:cas_base_url => cas_base_url
)
Modify your spec like this:
CASClient::Frameworks::Rails::Filter.fake(username)
visit '/'
Let me know if this works for you.
==================================================================================
Without using "CASClient::Frameworks::Rails::Filter.fake(username)" I too get the same error.
The reason is that cas redirects you to its base url with "/login?service=http%3A%2d%2Fwww.example.com%aF" a parameter like this.
And hence it complaints about missing route.
Check your test log
Make sure you have added the proper matching routes. it seems that you are missing routes.
I hope this helps you.
For writing routes you can get help from http://railscasts.com/episodes/79-generate-named-routes
I can access certain links from my site with no issue. However, if I try and manually type in the same URL as the link/button I get a 403 error.
FOr instance http://www.sumobid.com/logout.php
I have verfied the permissions on the file but am still getting the error.
This is on a dedicated server.
Any ideas?
Sounds like you're not logged in for the second case. I.e., you can't logout if you're not logged in.
Edit: I.e., it seems as if the app is throwing a 403 for pages that require auth but don't have it. (As opposed to, say, redirecting to the login page.)
Seems I fixed my own problem. It turns out that I had inadvertently turned on LinkProtection in cPanel. Once that was disabled everything started working as it should