I'm sure this question has been asked before, but I can't seem to find it. My devise sign up system was working fine yesterday; the emails were being sent, and clicking on the confirmation link in the email confirmed the account and redirected the user to the home page.
Today, the email still sends, but when I click on the confirmation link, I get the error message that "this webpage is not available," and the account isn't confirmed.
I recently switched from a vagrant virtual machine to nitrous.io, so this issue may have something to do with that . . . the url for my local version of my app isn't localhost:3000 anymore, and that's still what it says in the confirmation link. But the devise code doesn't specify localhost:3000, it specifies #resource. Since I don't have devise controllers, I don't know exactly what #resource refers to . . .
I realize this isn't much information, but I'm not sure what else to include. Does anyone have any ideas for me?
Thanks!
I'm guessing the link is directing you to rails server in development at localhost:3000. Change (or add) it in config/environments/development.rb .
config.action_mailer.default_url_options = { host: ..... } # eg. { host: 'localhost:3000' }
Your development.rb file needs to point to your hosted environment. So:
config.action_mailer.default_url_options = { host: 'http://something-yada.use1.nitrousbox.com }
That should take care of your issue. Remember localhost points to your local machine whereas Nitrous is a hosted environment.
Related
I have a rails app that's configured to force SSL:
Rails.application.configure do
config.force_ssl = true
end
It is then deployed to Heroku (free tier), where I configured to add my custom domain.
On Cloudflare, I only have these 2 records:
CNAME example.com example.herokuapp.com
CNAME www example.com
I also set the SSL option to be full.
My understanding is that, when people visit my webiste at www.example.com, they get redirected to the apex (non-www) url.
However, now whenever I visit the www version, it shows me the Heroku's No Such App page.
I have no idea what I did wrong and have tried all sorts of ways I have found online for a whole week. Hope someone can help me out, thanks!
Looking at the response from heroku 'No such App' found, please confirm if www.example.com is added as custom domain under settings?
I recently started following Hartl's Ruby on Rails tutorial.
I downloaded the existing sample_app_reference app from bitbucket.
My goal is not to start and learn everything from scratch but rather to add new features to the already existing app.
The issue is that I can't test the features I'm adding since I can't activate my account locally. In order to activate my account, I need to receive an activation email (which I'm not). I've searched the web for hours, but couldn't find anything regarding the issue. Did anyone try this tutorial before and encountered the same problem? Any help would be much appreciated.
Yeah...sending emails from dev environment is often not straightforward. As Vasilisa comments above, the quickest fix for your need is to activate the user from the rails console...perhaps like this:
% bundle exec rails console
my-app(development)> User.last.activate
However, there will be other times when you actually want to see the email in the context of a mail client. For this, https://mailcatcher.me/ makes it super easy. Just install the mailcatcher gem -- not in your app's Gemfile, but on your local machine's ruby installation.
Then, change the host and port in app/config/development.rb (NOT in other environemnts, like prod!)
config.action_mailer.smtp_settings = {
# For use with Mailcatcher: https://mailcatcher.me/
address: '127.0.0.1',
port: 1025
}
Run mailcatcher once from a command prompt.
Then, do your thing in your app to trigger an email send, and open http://127.0.0.1:1080/ in your browser. Voila, you see your email like it was really sent.
This a super-easy, super-useful way to see real emails without setting up your local env to actually send emails.
I have a rails 5 app that sends emails using Sendgrid. Those emails have links back into the app, such as <%= link_to "Reply on platform", conversation_url(#conversation) %>.
This all worked fine and dandy, until I added my SSL cert to the site. Now, all of the mailer links point to https://domain.com, instead of simply domain.com. When visiting https://domain.com, the site fails to load and throws an error saying "This site can’t be reached".
This is probably a simply fix that's right under my nose, but I'm having trouble putting my finger on it. Any advice?
Check your mailer configuration in production at config/environments/production.rb.
Make sure you have or add a line that says:
config.action_mailer.default_url_options = {host: "www.domain.com"}
I have a rails app on heroku, and a wordpress-heroku install also on heroku. I'm using the rack-reverse-proxy gem to redirect my wordpress to the /blog directory on my rails app. I followed all the instructions here:
http://rywalker.com/setting-up-a-wordpress-blog-on-heroku-as-a-subdirectory-of-a-rails-app-also-hosted-on-heroku
When I access my wordpress blog on its normal address, everything works fine. However, when I have it set up under a subdirectory of my rails app, I can't log in. I go to wp-login.php I enter my credentials, get forwarded to /blog/wp-admin.php, and then immediately I am redirected back to /blog/wp-login.php?redirect_to=http%3A%2F%2Flocalhost%3A3000%2Fwp-admin%2F&reauth=1. The only cookie that gets set is the wordpress_test_cookie, but none of the other wordpress cookies make any appearance in my browser.
I have tried many things to fix this including using rack-reverse-proxy to forward all rails traffic to wordpress, so I don't have to use a /blog subdirectory in case that was causing the problem. But the exact same behavior results. I've also determined that the :preserve_host setting in the Rack::ReverseProxy config doesn't seem to make any difference whether it's true or false.
Ideas?
A) What do you have in your wp-config.php? Should be something like this:
define('WP_SITEURL', 'http://www.DOMAIN.com/blog');
define('WP_HOME', 'http://www.DOMAIN.com/blog');
B) In the Rack::ReverseProxy settings, are you pointing to the blog (wordpress) herokuapp.com URL, not the main site (rails) URL, right? I realize my post isn't clear on that point.
I finally tracked this down to a bug in rack-reverse-proxy. The set-cookie header was being sent in an improper format, so only the first cookie was being interpreted correctly by the browser. That happened to be the wordpress test cookie. All the other (useful) ones were being thrown away, so of course I could not log in.
I plan to submit a bug and branch to rack-reverse-proxy but in the meantime I fixed it with this patch in my config.ru:
class MyReverseProxy < Rack::ReverseProxy
private
def create_response_headers(http_response)
response_headers = super(http_response)
if response_headers
if response_headers["Set-Cookie"].is_a?(Array)
response_headers["Set-Cookie"] = response_headers["Set-Cookie"].join("\n")
end
end
response_headers
end
end
# this is to make /blog show my wordpress blog
use MyReverseProxy do
reverse_proxy_options :preserve_host => false
reverse_proxy(/^\/blog(\/.*)$/, 'http://your-blog-server.com$1')
end
I'm using pow to host my rails app locally.
I've added devise and am trying to get omniauth to work following these steps.
when I visit http://my_site.dev/users/auth/twitter I get the following error -
URI::InvalidURIError
the scheme http does not accept registry part: my_site.dev (or bad hostname?)
Using the internal rails server works fine, visiting http://0.0.0.0:3000/users/auth/twitter works as expected.
Any idea what I'm doing wrong? Do I need to change something within pow?
Hostnames are not allowed to include underscores. Try this:
$ mv ~/.pow/my_site ~/.pow/my-site
The site will now be available under http://my-site.dev/.
You will need to edit your etc/hosts and set host there next go to twitter configuration page and set this url there. Probably it is set to localhost or something like this so he is not eager to trust it :).