Setting Up Devise & Sendgrid on Heroku - ruby-on-rails-3

My site is hosted on Heroku and I installed the Sendgrid Add-On as it looked almost too good to be true - but so far none of the email functionality is working. I have read the documentation and it clearly says just add-the add on - is more configuration required to get Devise working?
When I select 'send me new password' I get a 404 page which makes me think there is more to this. Like how does Sendgrid know/where to use the pre-installed Devise templates?
Thx.

I just set up Devise and SendGrid this morning and have no problems. I'm going to resume the steps I took.
First, install Devise and SendGrid. Congratulations, you've already done that ;)
Then, for production, add this to your files:
config/initializers/devise.rb :
config.mailer_sender = "mail-to-send#from.com"
Set up Rails ActionMailer to use SendGrid
config/environments/production.rb
config.action_mailer.default_url_options = { :host => 'your.websitedomain.com' }
ActionMailer::Base.smtp_settings = {
:user_name => ENV['SENDGRID_USERNAME'],
:password => ENV['SENDGRID_PASSWORD'],
:address => "smtp.sendgrid.net",
:port => 587,
:enable_starttls_auto => true,
:authentication => :plain,
:domain => "yourdomain.com"
}
And everything's working great with that. Sign up confirmations, password recovery...
Also, you should use Logging Expanded (it's Free!) and check your logs with heroku logs --tail (for real time).
If you still get errors, post your logs.
Have a good day !

I've used the sendgrid Add-On and it really should just work. Like you said, even the docs say so:
Rails apps using ActionMailer will just work, no setup is needed after the add-on is installed.
So, this makes me think something else is going on. Have you tried using the heroku logs command to see if your application is logging any errors?

Related

Devise-managed session not propagating to subdomains

I am using Devise to manage authentication in a Rails 3.1 application. It works just fine in my production server. But I just set up a new test server, and if I log in to the main site, accessing a subdomain is not recognizing the session. It's asking me to log in again.
I can't recall where I would troubleshoot this information. It seems as if it is some cookie setting.
I have domains pointed to each site, production and test. The production one ends in .net, the test version ends in .co.
Can anyone point me in the right direction?
I think this is not a devise setting but a session and cookie setting.
You can work on this by setting the variable YourApp::Application.config.session
You can do this in your environment.rb file or your config/initializers/session_store.rb. Example for session_store.rb is
YourApp::Application.config.session = {
:session_domain => '.yourdomain.com',
:session_key => '_yourapp',
:expire_after => 14*24*3600,
#:secure => true, #for secure/ssl sessions and such
:secret => 'somesecretgobledygook'
}
Please note the session_domain setting it to .yourdomain.com makes your cookies work across subdomains.
This applies to sessions. There are similiar settings for cookies.

Followed The Google OmniAuth tutorial but getting rejected from Server, how to read the rejection notice

This is the tutorial I followed. Scroll down to the Google open-id integration:
https://github.com/plataformatec/devise/wiki/OmniAuth:-Overview
On the server I get the following rejection message after clicking the login with google link:
WARNING: making https request to https://www.google.com/accounts/o8/id without verifying server certificate; no CA path was specified.
processing by users omniauthcallbackscontroller failure as html
EDIT the following two lines fixed the CA path Warning but did nothing to fix the failure as html problem or move me forward
require "openid/fetchers"
OpenID.fetcher.ca_file = "/etc/ssl/certs/ca-certificates.crt"
It then re-routes me to users/sign_in.
My devise config line looks like this:
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'), :name => 'google', :identifier => 'https://www.google.com/acounts/o8/id', :require => 'omniauth-openid'
My research tells me that I'm probably hitting the openID servers but that I'm getting rejected. Is there anyway to get more info from some sort of rejection notice? What could be wrong with my request?
One thing I thought of was credentials for open ID but I didn't see anywhere in the tutorial where I was supposed to get or enter any credentials.
Try to specify the ca_path:
config.omniauth :open_id, :store => OpenID::Store::Filesystem.new('/tmp'),
:name => 'google',
:identifier => 'https://www.google.com/acounts/o8/id',
:require => 'omniauth-openid',
:client_options => {:ssl => {:ca_path => '/etc/ssl/certs'}}
And see if it works.

How to do confirmation with devise authentication in Ruby on Rails

I am using devise in my application for authentication. When I try to register, I get the following error:
Missing host to link to! Please provide the :host parameter, set default_url_options[:host], or set :only_path to true
I am using :comfirmable and had uncommented t.confirmable in the migration
In order to use confirmable module you need to configure ActionMailer that is used by devise for sending confirmation emails. First step for solving your problem is setting up mailer host in you environment.rb or in the corresponding file for a particular environment like that:
config.action_mailer.default_url_options = { :host => “example.com” }
For further steps have a look at this rails guide and answers to this question.

Rails 3 - Help! Subdomains - Users Cannot Logout?

I've followed the ascii cast up at http://asciicasts.com/episodes/221-subdomains-in-rails-3
I've set the :domain option to :all in session store:
Rails.application.config.session_store :cookie_store, :key => '_bloggit_session', :domain => :all
Now my users cannot logout.
Any ideas why? I've tried deleting all cookies and then trying again, etc.
I can login, and my session is carried across subdomains, but I can't logout.
I am using rails 3, and authlogic for authentication.
Thanks for any help!
Specify the Domain.
I had the exact same issue and the culprit was using :domain => :all.
You'd think that would be all you need but it seems to cause some problems so I had to manually specify the domain with a preceding dot (.), like so:
:domain => '.lvh.me'
This fixed the issue in development. You can use different ways to set this in your various environments but I landed on something like this:
Rails.application.config.session_store :cookie_store,
:key => '_bloggit_session',
:domain => { production: '.bloggit.com',
staging: '.bloggitstaging.com',
development: '.lvh.me' }.fetch(Rails.env.to_sym)

Rails 3 devise i need help with confermation

I have watched the railscast on devise for some reason he pulled out the confrmation e-mail part so i have no idea how it works i have it up and running but what i need to know is dose it send an e-mail in development or not?
is there a way to force it to send the mail just to test it or can you enplane how to do it in the console!
it doesn't send email on development environment. You need to edit your config/environments/development.rb and add :
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
Then look in your console running your server when it try to send an email you will see actually all what your need there (headers, title and body email)