Can't Get Past Example 2-2 |
![]() ![]() |
Can't Get Past Example 2-2 |
Mar 27 2009, 12:50 PM
Post
#1
|
|
|
|
I set up AWS.rb with Examples 2-1 and 2-2 and inputed the example then get the error message -
NoMethodError: undefined method 'encode_base64' for #<Object:0xb7c709a4 @aws_secret_key="MySecretKey"> from .... in 'generate_signature' Any thoughts? |
|
|
|
Mar 28 2009, 07:14 PM
Post
#2
|
|
|
|
The encode_base64 method is not defined until Example 2-10 (Utility Methods), but I neglected to mention this correctly at this point in the chapter. Sorry about that.
You can either skip ahead to Example 2-10 to find the full implementation of this method, or you can temporary replace the call to the encode_base64 method with the following: b64_sig = Base64.encode64(digest) We added the encode_base64 method relatively late in the development of the book, after we discovered that the default Ruby base 64 encoding method (as listed above) adds newline characters to the result. These characters cause issues for the Amazon services discussed later in the book. I intended to add a reference to Example 2-10 before the test script listing, but this line mistakenly refers to Example 2-2. Thanks for reporting the issue. I hope this explanation and work-around helps. Regards, James P.S. Don't forget that all the example code is available for download, to save you typing it all out. You can find the code archive here: http://examples.oreilly.com/9780596515812/ This post has been edited by James Murty: Mar 28 2009, 07:29 PM |
|
|
|
Mar 28 2009, 07:26 PM
Post
#3
|
|
|
|
The book includes the following statement on page 29, just after Example 2-2:
Be sure to implement the encode_base64 method in Example 2-2 before you perform this test. This reference is incorrect and should point the reader to Example 2-10, which is where the encode_base64 method is defined. I have added a new entry to the book's errata for this error. |
|
|
|
Mar 30 2009, 03:50 PM
Post
#4
|
|
|
|
Thanks for the quick response, James. Your post worked for me.
I am new to Ruby so I like to type in the examples in the book, or any book like this when I am learning. Typing in all the examples helps me to learn the topic and the programming language. Usually I make a typo or two so I get to learn error messages, troubleshooting and debugging. I have downloaded the code but I haven't used it yet other than to double check examples 2-1 and 2-2. If I download and just use your code then I don't really learn anything. Love the book. Thanks again. The encode_base64 method is not defined until Example 2-10 (Utility Methods), but I neglected to mention this correctly at this point in the chapter. Sorry about that. You can either skip ahead to Example 2-10 to find the full implementation of this method, or you can temporary replace the call to the encode_base64 method with the following: b64_sig = Base64.encode64(digest) We added the encode_base64 method relatively late in the development of the book, after we discovered that the default Ruby base 64 encoding method (as listed above) adds newline characters to the result. These characters cause issues for the Amazon services discussed later in the book. I intended to add a reference to Example 2-10 before the test script listing, but this line mistakenly refers to Example 2-2. Thanks for reporting the issue. I hope this explanation and work-around helps. Regards, James P.S. Don't forget that all the example code is available for download, to save you typing it all out. You can find the code archive here: http://examples.oreilly.com/9780596515812/ |
|
|
|
![]() ![]() |
|
Lo-Fi Version | Time is now: 7th November 2009 - 12:32 PM |