|
Sam Ruby |
wikipedia href=”http://en.wikipedia.org/wiki/Sam_Ruby”>http://en.wikipedia.org/wiki/Sam_Ruby
Posts by Sam Ruby
|
27 Oct 2011, 15:59
Sam Ruby (549 posts) |
You will get that error if you are running ruby 1.8.7. Type
... which is to be expected as you are running erb without having first set the value of |
|
27 Oct 2011, 17:09
Sam Ruby (549 posts) |
Update: “soon” = now :-) |
|
27 Oct 2011, 18:56
Sam Ruby (549 posts) |
For the ruby version question, take a look at the “Choosing a Ruby version” sidebar on the second page of chapter 1. Also be aware that there are plans to stop supporting Ruby 1.8.7 starting late next year. So, yes, if you are new to this, you really should be starting with Ruby 1.9.2. As you are a Mac user, you can find instructions in section 1.2. The I would recommend that you either install Ruby 1.9.2, or be prepared to convert all of the examples to the Ruby 1.8.7 syntax, before debugging this further. |
|
28 Oct 2011, 16:57
Sam Ruby (549 posts) |
As one of the authors, I can certainly empathize with this. :-) I will, however, state that the Rails team works really hard to (for example) make sure that a working Rails 3.0 project will work on Rails 3.1. You can, again for example, leave your images in the public directory if you set What is true is that best practices are evolving rapidly. Additionally, the scaffolding generator changed drastically which caused the instructions in the 1st edition to be relatively useless (but the code previously generated would still mostly work). For Rails 3, a tool was created to help you with the specifics of an upgrade. |
|
30 Oct 2011, 18:13
Sam Ruby (549 posts) |
If I read that call stack correctly, you have two different versions of rake installed. What does Related reading: http://forums.pragprog.com/forums/148/topics/95… http://stackoverflow.com/questions/6181312/how-... Offhand, I don’t know the answer to your |
|
31 Oct 2011, 02:09
Sam Ruby (549 posts) |
There probably are three real errors in your code some place, probably typos or the like. Without seeing your code, this is hard to diagnose (except for the second one!). The first failure indicates that validation on urls is not taking place. Try creating a product using the web page with a URL of fred.doc and verify that you are getting the error you expect. The validation code that you are testing here should be in app/models/product.rb. The second failure looks like a simple typo: il8n should be i18n. The final failure is the opposite of the first: you are unable to create a product, presumably because of a validation failure. Look in test/functional/products_controller_test.rb for something wrong with the values that you are assigning to @update. Again, it might be helpful if you try entering these values using the web interface and verifying that you can create a product with these attributes. |
|
11 Nov 2011, 17:01
Sam Ruby (549 posts) |
Jeff: can you verify for me that you have updated your fixture? http://media.pragprog.com/titles/rails4/code/ra… The following is the output you should be seeing: http://intertwingly.net/projects/AWDwR4/checkde… As to RSpec and RCov, this book is about Rails and for better or worse Rails ships with test unit, so that’s what this book focuses on. If you want a book that focuses on testing, I suggest Rails Test Prescriptions: Keeping Your Application Healthy. |
|
12 Nov 2011, 19:31
Sam Ruby (549 posts) |
Long answer:
Depending on what you put in your helper, you might be able to get away with less than that. Much less. |
|
15 Nov 2011, 18:01
Sam Ruby (549 posts) |
Short answer: go into your Gemfile, modify the line that contains the ‘turn’ gem to look like this:
Once that is complete, execute the following command:
Longer answer: the turn gem (note this in the top of your exception traceback) has been updated to require a version of Minitest that is later than the version that Rails 3.1 supports. There is a version of Rails in beta now (3.1.2.rc-2) that pins down the exact version of the Turn gem in the way I specified above. The next version of Rails (3.2) will drop the Turn gem entirely—all it does is pretty print testing output. Based on where you are in the book, I would suggest simply making the changes above and not worrying about it further; these topics will be covered later in the book, but for now your best best is to focus on learning Rails before branching out. |
|
15 Nov 2011, 20:47
Sam Ruby (549 posts) |
What operating system are you using? If you are using Windows or Mac OSX, execjs is typically able to find a preinstalled runtime. If you are using Linux, the quickest way to get up and running is to install nodejs: |
|
16 Nov 2011, 15:19
Sam Ruby (549 posts) |
Can you verify that ExecJS can find a runtime?
People’s tastes in editor’s vary, but here’s a free editor that you can try: http://notepad-plus-plus.org/ |
|
16 Nov 2011, 22:05
Sam Ruby (549 posts) |
currency not defined means that you have defined currency in a module that you haven’t included in your current scope, so the include statement addresses this. The next problem you will find is that number_to_currency is not defined, and that’s what the rest of the lines help with. For more information, scan ahead to section 24.2. This information is at the bottom of that section. |
|
16 Nov 2011, 22:30
Sam Ruby (549 posts) |
I’m not sure where the best place is to ask execjs support questions, but it does appear that one of the supported runtimes, namely node.js, now has a Windows installer: I don’t have a Windows machine that does NOT have JScript (after all, it is a part of IE) to test out if Node.js is a viable alternative on windows to test this out in advance, but perhaps you can try it. |
|
20 Nov 2011, 14:46
Sam Ruby (549 posts) |
Can someone please point me to where I can find this in book version 2.1? First “Playtime” exercise at the end of chapter 10. These exercises are optional, but solutions to selected ones (including this one) are included in the downloadable code. You can find hints (as well as follow the link to the solution in this case) on the wiki: |
|
20 Nov 2011, 20:14
Sam Ruby (549 posts) |
depot_n (and depot_r) have the migration that is used to add price to line item: |
|
21 Nov 2011, 02:47
Sam Ruby (549 posts) |
Perhaps this will help: http://hello.keewooi.com/ruby-1-9-3-preview-1-a… |
|
21 Nov 2011, 18:56
Sam Ruby (549 posts) |
Parenthesis are optional in method calls, so the above is exactly equivalent to |
|
22 Nov 2011, 07:32
Sam Ruby (549 posts) |
product.errors[:price] is an array of errors, after all, there may be multiple errors associated with that one field.
We could separately verify that the length of this array (and therefore the number of errors associated with this field) is exactly one AND that the first such error is the one that we are expecting, or we can simply concatenate all of the errors and verify that the result is what we are expecting. assert product.invalid? is arguably redundant in this particular example, and certainly less precise than checking for a specific error message. It does have some minimal value in that it checks that there not only is a message, but that this field has been flagged as in error.
If no error message is passed, |
|
25 Nov 2011, 01:52
Sam Ruby (549 posts) |
(from Agile Web Development with Rails 3.2 > 11.6 Testing AJAX Changes "NoMethodError in Carts#index")
This suggests that |
|
16 Dec 2011, 16:12
Sam Ruby (549 posts) |
Admittedly a shot in the dark: possible file permission problem? On Mac machines, the web server runs with the effective user id of _www. Make sure that your directories have both read and execute permissions set, and that your files have the read permission set. |
|
24 Dec 2011, 15:49
Sam Ruby (549 posts) |
Thanks for the errata, it will be fixed in the next update. |
|
28 Dec 2011, 12:58
Sam Ruby (549 posts) |
E M: I use Firefox (and Firebug), but you might be able to do the same things with Safari’s Web Inspector has most of the same functionality. Based on what you have described, the button did send a “remote” request to the server, and the server produced a response. The first thing to verify (view-source will suffice) is that your page has an element with an id of cart:
Next, enable Tools => Web Developer => Web Console, and issue your request. If there are any JavaScript errors, they will show up in the console. The console will also show when a POST request is issued, and what the HTTP response is. If this doesn’t show the problem, enable Tools => Web Developer => Firebug => Open Firebug. Click on the Net tab, then XHR. Now issue the request again. You should see a POST line show up in Firebug. Click on the +, then click on response. What you should see should look something like: |
|
28 Dec 2011, 19:58
Sam Ruby (549 posts) |
First, I will assume that the “1 request” is on the next line? If that were to be a part of the response, you would get a JavaScript error. Looking at the response itself, I see “smart” quotes in places – backtics instead of apostrophe’s around #cart, and the first and last double quote on the call to html is a close quote. I don’t know if this was a part of the response or was mangled by this forum software. But in any case, try doing this again, then select and copy the entire response to the clipboard. Then select the console tab. At the bottom of the screen you should see three greater than signs. Paste the response there then hit enter. If the response is correct, it should update the cart. If not, you should see the error. If you press the up-arrow key you should be able to retrieve the text, edit it, and press enter again. Once you get it working, change the code on your server to produce the response that works. |
|
06 Jan 2012, 11:07
Sam Ruby (549 posts) |
HAML works for me, using the instructions provided in the book, with Rails 3.1: |
|
12 Jan 2012, 02:49
Sam Ruby (549 posts) |
Gemfile: http://media.pragprog.com/titles/rails4/code/ra… The name of the view file should be index.html.haml: |
549 posts
