Running OSX Mavericks, ruby 2.1.1p76 (2014-02-24 revision 45161) [x86_64-darwin13.0], rvm 1.25.23 (master), and rails-4.1.0 (allegedly)
I'm working through the railsapps.org book on learning rails I have finished implementing the mailchimp email list code, and when I press submit on my form, I get the following error:
URI::InvalidURIError at /visitors
the scheme https does not accept registry part: us8'.api.mailchimp.com (or bad hostname?)
My debug screen seems to indicate that it's failing at the call
result = mailchimp.lists.subscribe({
:id => Rails.application.secrets.mailchimp_list_id,
:email => {:email => self.email},
:double_optin => false,
:update_existing => true,
:send_welcome => true
})
I have my API key and List IDs both hard coded into secrets.yml, so I know they are correct.
Any ideas?
Regards,
Jeff
The error message indicates that the URL used to contact the Mailchimp server is malformed.
The Gibbon gem constructs the HTTPS request to the Mailchimp server and uses the httparty gem to make the HTTPS request. We can be confident that Gibbon works as expected. You can check the Gibbon issues to confirm; I just did and saw no reported problems like yours.
So we know Gibbon is working, and we can presume the code from the learn-rails tutorial application works (because no one else has reported this problem). So what can be the cause of the problem? My guess is that your API key is incorrect. It may have an extra single quote that does not belong. I'm guessing that something about the API key is preventing Gibbon from forming a correct URL string.
You can diagnose by entering a correctly formatted but wrong API Key. Instead of the URL error should get a response from the Mailchimp server that your API key is not known.
Related
Since upgraded to Ruby 2.2.0 I get the following message in my tests:
invalid salt (BCrypt::Errors::InvalidSalt)
I didn't find any upgrade notice helping me to understand the problem. I'm using Rails 4.1.8 and Sorcery 0.8.6.
Anybody else having this problem?
MORE Details:
I'm using Sorcery and not Devise. The encrypted data is the password.
It all started in Cucumber tests, in 2 cases:
When I used to send the #user to the mailer to prepare the data for the mails. Here was the code:
UserMailer.passphrase_reset_notification(#user).deliver
Which generated the exception with the message I wrote in the initial message. As a workaround instead of sending the #user I sent the fields I needed and it worked. Here's the new code:
UserMailer.passphrase_reset_notification(#user.name, #user.email).deliver
But the second case is the sign up. It failed in dev and I had to add :salt to user_params to fix it. But it does not fix the thing in the test env.
There's no stack trace, just that one liner message with the lines of my scenario leading to the error.
And I press "Sign up"
invalid salt (BCrypt::Errors::InvalidSalt)
./app/controllers/users_controller.rb:66:in block in create'
./app/controllers/users_controller.rb:64:increate'
./app/controllers/application_controller.rb:120:in scope_current_tenant'
./features/step_definitions/web_steps.rb:53:in/^(?:|I )press "([^"]*)"$/'
features/users/sign_up.feature:149:in `And I press "Sign up"'
I removed the "null: false" for the field "salt" in the user table, as suggested by a community member in a post on a more or less similar issue, it didn't help either.
My main question is still the same: what the Ruby new version (2.2.0) has to do with this? And what might be the other surprises if I upgrade the prod?
I just fixed this. Turned out it had to do with serializing an object with has_secure_password (which uses bcrypt-ruby)
More specifically, something like the following was causing the issue with Sidekiq as it tried to serialize arguments into objects for Redis queueing.
#user = User.new(
:firstname => 'Scott',
:lastname => 'Klein',
:password => 'mypass',
:password_confirmation => 'mypass'
)
#user.save!
# broken
# note that #user.password can still be called here
# and sidekiq will attempt to serialize this whole object using YAML
# and this is the serialization issue that barfs (in the depths of YAML)
UserMailer.delay.new_user_signup(#user)
# fixed
# i just passed the id and then recalled the user record in the mailer class
UserMailer.delay.new_user_signup(#user.id)
I've had similar problem. Investigation made me conclude that it's bcrypt not playing well with Psych (that's the Ruby system library for generating and parsing YAML).
There's an open bcrypt issue now. Waiting for gem author to fix it.
** FIXED **
The problem, at least mine, is fixed. I just upgraded the bcrypt gem from 3.1.
9 to 3.1.10 and it was it! Thanks Oleg to have created an issue on bcrypt account.
I have a rails application. Rails version is 2.3.4 and ruby version 1.8.7. In that application I used geokit (1.5.0) gem and geokit-rails plugin to find nearest location.
And in my model I have code like this,
class Notary < ActiveRecord::Base
acts_as_mappable
end
And in my controller have code like this,
class Client::OrdersController < ApplicationController
def find_notary
#order = Order.find(params[:id])
#miles = 10
unless params[:notary_search]
#notaries = Notary.find(:all, :origin => #order.signing_location_zip_code, :within => #miles, :conditions => "on_vacation IS NOT true",:order=>"distance asc" )
else
some code
end
end
end
I am getting error in that line
#notaries = Notary.find(:all, :origin =>
#order.signing_location_zip_code, :within => #miles, :conditions =>
"on_vacation IS NOT true",:order=>"distance asc") like this,
Geokit::Geocoders::GeocodeError in
Client/ordersController#find_notary
Geokit::Geocoders::GeocodeError
RAILS_ROOT: /home/user/svnnew_app/trunk/app
Application Trace | Framework Trace | Full Trace
/home/user/.rvm/gems/ruby-1.8.7-p371#app/gems/geokit-1.5.0/lib/geokit/mappable.rb:282:in
`normalize'
/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:347:in
`normalize_point_to_lat_lng'
/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:306:in
`extract_origin_from_options'
/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:203:in
`prepare_for_find_or_count'
/home/user/svnnew_app/trunk/app/vendor/plugins/geokit-rails/lib/geokit-rails/acts_as_mappable.rb:108:in
`find'
/home/user/svnnew_app/trunk/app/app/controllers/client/orders_controller.rb:331:in
`find_notary'
Request
Parameters:
{"id"=>"1198"}
Show session dump Response
Headers:
{"Cache-Control"=>"no-cache", "Content-Type"=>""}
How to resolve this error? Please help me out..
I maintain geokit. I had a look at the source code and that line happens when the response back from the API isn't numeric, e.g. a string but not in the format '99.99, 88.88', so would happen if the geocoding API returned 'NA' or something for example.
And I know StackOverflow says "avoid" the following (clarification, opinion, etc.), but here it is:
I can't help further without you doing a few things:
1) If you could update to the latest geokit (gem: 1.7.1 or the latest github master)
2) Do some debugging, e.g. Open "/home/user/.rvm/gems/ruby-1.8.7-p371#app/gems/geokit-1.5.0/lib/geokit/mappable.rb" (line 282) and least "puts" the string that is causing the error along with any other relevant local variables.
Using gems like pry/pry-debugger are a must for any ruby developer to debugging such issues.
3) Update other software where possible (even upgrade to latest ruby 1.8.7 and rails 2.x)
You're ruby (1.8.7) and rails (2.x) both are quite old and contain various security issues which should be of some concern. I do my best to keep geokit/geokit-rails working with ruby 1.8.7, but even rails 2 compatibility was dropped in geokit-rails, although I'm happy to help because likely you issue is a problem in geokit-rails with supported rails versions.
I'm using Rails 3.1 and ActiveMerchant 1.17
I'm calling the PaymentExpress gateway, using the correct test credit card details. However, it keeps giving some form of invalid response.
The most I can make out is that the response.params array contains
{"re_co"=>"Zz", "response_text"=>"Error in getting response.", "success"=>"0"}
This is using the local rails server.
I have a hunch that it may be to do with the SSL verify_peer option, though I have no way of proving that, and I have no idea how to configure that option.
This is my code, fairly standard stuff:
credit_card = ActiveMerchant::Billing::CreditCard.new(params[:credit_card])
gateway = ActiveMerchant::Billing::PaymentExpressGateway.new(:login => APP_CONFIG[:dps_username], :password => APP_CONFIG[:dps_password])
response = gateway.authorize total_cents, credit_card
Interestingly, it seems to work fine from the rails console. Are there any steps I should be taking to debug this?
Ok, it turns out the problem wasn't to do with ActiveMerchant at all.
I should have been using
APP_CONFIG['dps_username']
instead of
APP_CONFIG[:dps_username]
Ahh, the simple problems
I am trying to use an OmniAuth (0.2.6) strategy for my application. The architecture is Rails 2.3.10 and Rack is version is 1.1 (this version or higher is required for OmniAuth). A problem that occurs is Rails doesn't recognize my redirect to "/auth/provider". The actual error message is "No route matches "/auth/casport". Even though that error gets thrown, the code seems to execute past that point up to this error: "request.env['omniauth.auth']", which I'm pretty sure means it doesn't recognize the "omniauth.auth" key for the env hash. I have a feeling that OmniAuth isn't being loaded properly. I've tested the same strategy and code base with Mongrel and Webrick, and I get identical error messages.
Here is my OmniAuth initializer (config/initializers/omniauth.rb):
ActionController::Dispatcher.middleware.use OmniAuth::Builder do
provider :casport, :setup => true
end
I definitely have routes in places for auth/casport/setup and auth/casport/callback.
I've also tried this approach: How do you implement OmniAuth on Rails 2.2?
config.middleware.use OmniAuth::Builder do
provider :casport, :setup => true
end
by placing that middleware code in the config/environments/development.rb file.
Does anyone have any thoughts on what I could be doing incorrectly? Thanks!
Edit: I've also tried this approach Has anyone used omniauth with rails 2.3.8?
ActionController::Dispatcher.middleware.use OmniAuth::Strategies::Casport = {
:setup => true
}
and that returns a read error: "NoMethodError: undefined method 'new' for #Hash...
Edit 2: I've upgraded to Rails 2.3.10 as OmniAuth isn't compatible with Rails 2.3.4.
I created an issue on OmniAuth's Github page https://github.com/intridea/omniauth/issues/397, with the above details and this is the response from Michael Bleigh, the creator of OmniAuth:
"OmniAuth has never officially supported Rails 2.3.x -- I've heard that some people have had luck with it but it's not something that is guaranteed. Sorry!"
So it looks like the methods I posted above may work for some folks. To guarantee correct operation, Rails 3 is needed.
I'm having trouble sending mail using SMTP from a Rails app. I have a Mailer class:
class Mailer < ActionMailer::Base
def newsletter_confirmation(subscription)
recipients "my-valid-email#gmail.com" # this is set to my email
# just for testing purposes and will
# be changed to subscription.email
from "\"my-valid-helo-domain.net\" <noreply#my-valid-helo-domain.net>"
subject "Confirm your subscription"
body :subscription => subscription
end
end
When I try to send the mail, I get a Net::SMTPSyntaxError:
501 <["noreply#my-valid-helo-domain.net"]>: missing or malformed local part
If I comment out the from field, the mail gets delivered ok, but with the from information missing (obviously). Any ideas on what I'm doing wrong?
Thanks.
Edit: I'm using Rails 2.3.2 and Ruby 1.9.1
The error code and the description of the error states that this is an error on the mail server.
I suggest you check the mail servers to pinpoint the error.
When it comes to ActionMailer it is supposed to raise an exception if the configuration parameter raise_delivery_errors is set (default in Production but not in Development I believe), so you can check that one and try to resend if it triggers.
EDIT:
Here is the solution (it's a Ruby/Rails 1.9 bug):
https://rails.lighthouseapp.com/projects/8994-ruby-on-rails/tickets/2340-action-mailer-cant-deliver-mail-via-smtp-on-ruby-191
and the patch:
https://rails.lighthouseapp.com/projects/8994/tickets/2340/a/104008/action_mailer-ruby-1.9-from-address-fix.patch
It is a known bug. https://rails.lighthouseapp.com/projects/8994/tickets/2340