Thank you Ryan, very interesting episode!
I'm trying to get the mailer to work on heroku. I did heroku addons:add sendgrid:starter
but whenever I try to send an email from heroku, I get this error:
ruby
2012-07-18T23:14:05+00:00 heroku[router]: GET guestlist12.herokuapp.com/assets/application-ea8b32131f736b7d8bc98f7cb199c9cf.css dyno=web.1 queue=0 wait=0ms service=11ms status=304 bytes=02012-07-18T23:14:10+00:00 app[web.1]:
2012-07-18T23:14:10+00:00 app[web.1]:
2012-07-18T23:14:10+00:00 app[web.1]: StartedPOST"/password_resets"for68.5.179.249 at 2012-07-1823:14:10 +00002012-07-18T23:14:10+00:00 app[web.1]: Processing by PasswordResetsController#create as HTML2012-07-18T23:14:10+00:00 app[web.1]: Parameters: {"utf8"=>"✓", "authenticity_token"=>"H1VHMVJocUWdwzwVV0AbLB1Pfqgug+jT846sE794ISA=", "email"=>"cedric.waldburger@mediasign.ch", "commit"=>"Reset Password"}
2012-07-18T23:14:10+00:00 app[web.1]: Rendered user_mailer/password_reset.text.erb (0.8ms)
2012-07-18T23:14:13+00:00 app[web.1]: Sent mail to cedric.waldburger@mediasign.ch (3117ms)
2012-07-18T23:14:13+00:00 app[web.1]: Completed500InternalServerErrorin3410ms
2012-07-18T23:14:13+00:00 app[web.1]:
2012-07-18T23:14:13+00:00 app[web.1]: app/models/user.rb:37:in`send_password_reset'
2012-07-18T23:14:13+00:00 app[web.1]:
2012-07-18T23:14:13+00:00 app[web.1]: app/controllers/password_resets_controller.rb:7:in `create'
2012-07-18T23:14:13+00:00 app[web.1]: Errno::ECONNREFUSED (Connection refused - connect(2)):
Anyone else had this problem? Any ideas how to fix this?
I was following both omniauth episodes in order to get my app running with twitter authorization.
Unfortunately I am stuck when i call /auth/twitter .
I get redirect to my page to the create action in the AuthenticationsController
the weird thing ist that authentication.user is nil when in try to call sign_in_and_redirect
My validations model contains the belongs_to :user relation, but apparently it can not find the associated user.
Any help would be appreciated.
Thanks in advance.
Philip
def create
auth = request.env["omniauth.auth"]
authentication = Authentication.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
if authentication
flash[:notice] = "Signed in successfully."
puts authentication
puts authentication.user
sign_in_and_redirect(:user, authentication.user)
else
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "auth successfull"
redirect_to authentications_url
end
end
normal registration form is also not showing the password field ..
how can I make sure its shown for users who want to register through site and not show the pass for user from oauth ..
Ryan - Thanks for this awesome RailsCast. I was trying to figure out RSpec and this made so much sense. Please create new RailsCasts about testing as your process changes and the tools improve.
How would this work with other query parameters such as searches or paging? It seems that a simple search parameter added to the model is not recognized after the find_with_reputation call.
I've taken the concept of if a user has voted for something and taken it a step further. The user can see if they have up voted something or down voted something.
Had the same error...I ended up removing the ENV and [] from the CONSUMER_KEY and CONSUMER_SECRET in the devise.rb initializer file. I also used http://127.0.0.1:3000/auth/twitter/callback as my callback URL in the Twitter App settings and it seemed to fix the error for me. In case it matters, in the Website field I used my production url...http://myappname.com. Hope this helps.
So I discovered an odd problem with using Capistrano::CLI.password_prompt "PostgreSQL Password: "
I spent most of the day trying to figure out why I was getting this error FATAL: password authentication failed for user "DBuser"
at the bundle exec rake RAILS_ENV=production db:migrate
stage of my cap deploy:cold.
Turns out that when I use special characters when prompted for the db user password during cap deploy:setup, the cold deploy fails. But if I use a password without any special characters then the cold deploy works.
I don't know why this would be the case, so if anyone has any ideas as to why special characters can't be used, I'd love to be enlightened.
I agree with your point of solving this in a model instead of a sweeper in the controller. It took me a couple of hours to solve this problem the IMO proper way.
Add the following to your model in a Rails 3.2 app (here the Class is Company):
ruby
after_create :expire_cache
after_update :expire_cache
before_destroy :expire_cachedefexpire_cacheActionController::Base.expire_page(Rails.application.routes.url_helpers.company_path(self))
ActionController::Base.expire_page(Rails.application.routes.url_helpers.companies_path)
end
Hi everyone.. I have to say, setting it up initially wasn't very easy. Turns out rubber is not very happy with "complex" database.yml (with conditional environment if's etc..) or with hyphens in the app name which, at least when using mysql templates, confuse rubber.
After having fixed a few annoying issues - and separating the credentials, I now have a weird issue (and a question below):
The problem I hope someone can shed some light on:
cap rubber:create_staging runs without errors. However, it ends with the same output as rubber:bootstrap does. i.e. the last command is:
* executing "sudo -p 'sudo password: ' bash -l /tmp/create_master_db"
and never actually fires up an apache/passenger to run my app.. and thus the link is not accessible.
Also, a bit above, collectd throws an error:
** [out :: production.foo.com] Starting statistics collection and monitoring daemon: collectd
** [out :: production.foo.com] configfile: stat (/etc/collectd/conf.d/*.conf) failed: No such file or directory
Can collectd be the reason why my app doesn't actually start? I'm using rubber 2.0.5 by the way. Or may it be that it requires me to run another command to get things started (even on staging)?
And the other question:
I'm using the complete_passenger_mysql template - which hopefully includes everything - but was tempted to use complete_passenger_nginx_mysql - any benefit in doing this instead??
This is what I'm experimenting with, not sure if there's a better way:
entry << "<media:thumbnail url=\"#{post.thumbnail.tiny}\" width='200' height='200' />".html_safe
twitter_id, facebook_id, linkedin_id, plus_id work for me.
Performance-wise I would say it's just extraneous joins or database calls to get the info.
If they aren't authenticated with that service the value is null.
Normalization here is not necessary due to the has_many relationship being constrained.
Thank you Ryan, very interesting episode!
I'm trying to get the mailer to work on heroku. I did
heroku addons:add sendgrid:starter
but whenever I try to send an email from heroku, I get this error:
Anyone else had this problem? Any ideas how to fix this?
Thanks in advance!
You are a GOD.
hi,
I was following both omniauth episodes in order to get my app running with twitter authorization.
Unfortunately I am stuck when i call /auth/twitter .
I get redirect to my page to the create action in the AuthenticationsController
the weird thing ist that authentication.user is nil when in try to call sign_in_and_redirect
My validations model contains the belongs_to :user relation, but apparently it can not find the associated user.
Any help would be appreciated.
Thanks in advance.
Philip
def create
auth = request.env["omniauth.auth"]
authentication = Authentication.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
if authentication
flash[:notice] = "Signed in successfully."
puts authentication
puts authentication.user
sign_in_and_redirect(:user, authentication.user)
else
current_user.authentications.find_or_create_by_provider_and_uid(auth['provider'], auth['uid'])
flash[:notice] = "auth successfull"
redirect_to authentications_url
end
end
With the facebook.js.coffee.erb the auth variable, in user model, is nil! I don't understand why! Someone can I help?
I solved it downgrading to 2.1.0. I was using version 2.1.1.
Hi everyone.
I did this exaple and works great.
I just have one question.
In the next code, ¿how I can change the label for the button?
Regards.
So how would i go about redirecting a new user to a profile model so that they could fill in extra details about themselves?
Found it: http://www.stefanoforenza.com/how-to-repeat-a-shell-command-n-times/
Is repeat a ZSH command? Is that available for bash? I can't figure out where you got it.
Can someone point me in the right direction?
def sweep not working for me.
this yes:
Just had to add: ActionController::Base.new.expire_fragment
Remember to set the
Content-Disposition
header for such downloads.thanks..
Cheers Pranay.
In case anyone else is using Kaminari - you might need to change '.next_page' to '.next' :)
seconding juliamae's comment. this looks old if you're using rails 3.
"Rails 3 Way" has a chapter on authlogic.
seconding juliamae's comment. this looks old if you're using rails 3.
The "Rails 3 Way" book has a chapter on authlogic.
^^ If you just use 127.0.0.1:3000 for the callback, it works.
Back button ... I'd like to know as well!
in other words, please tell how to make it registrable + omniauthable
normal registration form is also not showing the password field ..
how can I make sure its shown for users who want to register through site and not show the pass for user from oauth ..
Regards
I'd love to send the email not only to the user but to myself as well. How would you do that?
Another +1 for TorqueBox.
Hi Ryan, great episode indeed, well worth $9 itself.
I'm pretty curious about how to implement authentication via multiple services too. Any episode taking that path soon?
Ryan - Thanks for this awesome RailsCast. I was trying to figure out RSpec and this made so much sense. Please create new RailsCasts about testing as your process changes and the tools improve.
I don't use it.
Combine the definition together?
How would this work with other query parameters such as searches or paging? It seems that a simple search parameter added to the model is not recognized after the find_with_reputation call.
I've also used cancan to limit the user from voting on their own Answer/Question/Post.
I've taken the concept of if a user has voted for something and taken it a step further. The user can see if they have up voted something or down voted something.
This came in handy when I was checking to see if the user has up voted or not so I could change the image.
Had the same error...I ended up removing the ENV and [] from the CONSUMER_KEY and CONSUMER_SECRET in the devise.rb initializer file. I also used http://127.0.0.1:3000/auth/twitter/callback as my callback URL in the Twitter App settings and it seemed to fix the error for me. In case it matters, in the Website field I used my production url...http://myappname.com. Hope this helps.
Did you ever find the answer for this Ben?
Interesting talk at NDC 2012 on not so well known tid bits of Postgres
So I discovered an odd problem with using
Capistrano::CLI.password_prompt "PostgreSQL Password: "
I spent most of the day trying to figure out why I was getting this error
FATAL: password authentication failed for user "DBuser"
at the
bundle exec rake RAILS_ENV=production db:migrate
stage of my
cap deploy:cold
.Turns out that when I use special characters when prompted for the db user password during
cap deploy:setup
, the cold deploy fails. But if I use a password without any special characters then the cold deploy works.I don't know why this would be the case, so if anyone has any ideas as to why special characters can't be used, I'd love to be enlightened.
you might be interested in this book? recently released by Pragmatic Programmers - http://pragprog.com/book/jkdepj/deploying-with-jruby "Deploying with JRuby: Deliver Scalable Web Apps using the JVM"
Torquebox is great and has it own screencasts : http://torquebox.org/podcasts/
I agree with your point of solving this in a model instead of a sweeper in the controller. It took me a couple of hours to solve this problem the IMO proper way.
Add the following to your model in a Rails 3.2 app (here the Class is Company):
Hi,
I did all like in the guide, but on failed registration I got the following:
Details of my issue can be found at http://stackoverflow.com/questions/11506734/routing-error-no-route-matches-when-omniauth-failed-on-registration
Does anybody have any ideas what can be the reason for this?
Are there any solutions for integration testing to verify that secure cookies work as I expect?
hi,
i can not use symbol '€', anyone can help me ?
Ryan, thanks for another excellent railscast!
Hi everyone.. I have to say, setting it up initially wasn't very easy. Turns out rubber is not very happy with "complex" database.yml (with conditional environment if's etc..) or with hyphens in the app name which, at least when using mysql templates, confuse rubber.
After having fixed a few annoying issues - and separating the credentials, I now have a weird issue (and a question below):
The problem I hope someone can shed some light on:
cap rubber:create_staging runs without errors. However, it ends with the same output as rubber:bootstrap does. i.e. the last command is:
* executing "sudo -p 'sudo password: ' bash -l /tmp/create_master_db"
and never actually fires up an apache/passenger to run my app.. and thus the link is not accessible.
Also, a bit above, collectd throws an error:
** [out :: production.foo.com] Starting statistics collection and monitoring daemon: collectd
** [out :: production.foo.com] configfile: stat (/etc/collectd/conf.d/*.conf) failed: No such file or directory
Can collectd be the reason why my app doesn't actually start? I'm using rubber 2.0.5 by the way. Or may it be that it requires me to run another command to get things started (even on staging)?
And the other question:
I'm using the complete_passenger_mysql template - which hopefully includes everything - but was tempted to use complete_passenger_nginx_mysql - any benefit in doing this instead??
another +1 for TorqueBox.
Any Luck Here Tarik?
Getting the same error after authenticating Facebook via javascript based asynchronous call.
It works if I use the standard method where I am directed to login via Facebook website.
Thanks indeed for any help.
"config.active_record.whitelist_attributes = true" only works in Rails 3.1 or greater.
Thanks buddy!! :)
Thanks Ryan, I have been waiting for this one for some time now.
Will, Thanks for sharing this. It's great to learn useful things in the comments section of Ryan's awesome site, too!
I think it may be that it's more efficient to pass simple types to delayed methods as they get serialized and stored in the jobs table?
+1
As all ways great episode!
It would be nice if you could make an episode on the topic of creating a oauth service with devise and doorkeeper.