’
irb(main):023:0> Product.select(:select => “id, title”)
(Object doesn’t support #inspect)
=>
By Developers, For Developers
PDF Pg | Paper Pg | Type | Description | Fixed on | Comments |
---|---|---|---|---|---|
11 | TYPO | “significantltly refactored” s/b “significantly refactored” | 2010-04-14 | ||
26 | TYPO | Seems that rails 3.0.0.beta3_ —version should be rails 3.0.0.beta3 —version on line 4 | 2010-04-14 | ||
63 | TYPO | “YAML is used as convenient way…” should be “YAML is used as a convenient way…”. An “a” should be added. | 2010-04-14 | ||
25 | TYPO | The text at the beginning of this page, “develop this book so that you can be absolutely confident that the output and examples exactly match”, doesn’t make sense as a continuation of the sentence at the end of the previous page. | 2010-04-14 | If you look real close, you will see the very tops of some characters at the bottom of page 24. The obscured text is as follows: \n \n[For example] ... you might want to run the version of Rails that matches this version used to ... [develop this book so that you can be absolutely confident that the output and \nexamples exactly match.] \n \nThis will be corrected in the next beta. | |
133 | ERROR | At this page We are expecting to get the cart list showing the total price. But its not showing any out instead at this moment we are getting an error because the total_price function for particular book is not defined means error at line number 7 of show.html.erb file under views of carts. Cause you people forget to add def total_price function in line_item.rb file. | 2010-04-15 | ||
48 | TYPO | Third sentence in second paragraph reads: “It also asks | 2010-04-15 | ||
49 | TYPO | 2nd line on page: “choses” should be “chooses” | 2010-04-15 | ||
18 | OK | under Ruby Tips | 2010-04-16 | You do need to know Ruby to write Rails applications, and that's why this book includes an introduction to Ruby. | |
96 | TYPO | Third paragraphy after Text Fixtures heading. Second sentence reads: “These files contain | 2010-04-16 | ||
44 | TYPO | Extra >’s at the end of the lines: | 2010-04-16 | ||
97 | TYPO | The product listed in depot_c/test/fixtures/product.yml has a title of Title One. On the first line of page 98 it is referred to as the Ruby book and again on the first line of the second paragraph of page 99 | 2010-05-08 | ||
24 | TYPO | The sentence continuing on to page 25 is missing something. Looks like the red banner at the bottom of 24 might be obscuring a line of type. | 2010-05-03 | ||
26 | SUGGEST | “See on page 221” should be just “See page 221” | 2010-04-20 | ||
64 | TYPO | which inherits from the Migration class from the ActiveRecord “module” | 2010-04-20 | ||
132 | ERROR | In order for total_price method to work I had to move it from the cart model to the line_item model lass LineItem < ActiveRecord::Base def total_price | 2010-04-20 | ||
109 | TYPO | The command on the final line should be ‘rake test’ not ‘rake tests’. | 2010-04-20 | ||
83 | TYPO | In the printout of “depot_b/app/views/layouts/application.html.erb”, the line: Has depot listed as the stylesheet name, but we haven’t changed it yet. It should have the stylesheet name of ‘scaffold’ still, or: <%= stylesheet_link_tag :all, ‘scaffold’ %> | 2010-04-23 | Two paragraphs above this point, the depot stylesheet should have been downloaded. I've updated the text to make this clearer. | |
35 | TYPO | “SayController is an class” should be “a class” | 2010-04-20 | ||
147 | ERROR | You are adding this line of code But there is no such thing know as items in cart. We are having line_items in a cart,So this must be | 2010-04-20 | ||
11 | SUGGEST | There’s no indication of who wrote the main part of the Acknowledgements, just the pieces from Sam and Dave. | 2010-11-20 | ||
115 | TYPO | At the end of the first line it should be ‘a cart’ not ‘an cart’. | 2010-04-20 | ||
117 | TYPO | I might be getting a bit over zealous here but, in the last paragraph it states ‘All we need to modify is two lines of code’ which is correct but we also need to add two lines of code as well. | 2010-04-20 | ||
126 | TYPO | In the final paragraph it says ‘giving it a product id of wibble’, this should be ‘giving it a cart id of wibble’ | 2010-04-20 | ||
127 | TYPO | Third paragraph refers to ‘bad product ids’ should read ‘bad cart ids’ | 2010-04-20 | ||
28 | SUGGEST | I think BBEdit is worth mentioning alongside TextMate. Version 9 implemented a lot of the features listed on pp. 27-28. | 2010-11-10 | ||
65 | TYPO | Second line on page: “easy of authoring” probably should be “ease of authoring”. However, that phrase also sounds awkward. | 2010-04-20 | ||
44 | TYPO | Extra brackets at end of bullet 2 and 3 under ‘Playtime’ | 2010-04-20 | ||
94 | SUGGEST | Instead of using !product.valid?, IMHO I think using product.invalid? is more descriptive. | 2010-04-20 | ||
103 | OK | Should also remove /images/rails.png file as it’s not used anymore. depot> rm public/images/rails.png | 2010-05-03 | ||
166 | ERROR | The output shown on this page is not working cause you forget to add a relationship in order model ie order.rb Here it is | 2010-04-24 | ||
43 | TYPO | “Constructed a toy application showed us the following:” change to “which showed” | 2010-04-20 | ||
123 | SUGGEST | Please remove line 3 of line_items_controller.erb | 2010-04-20 | I changed it so that product is used... and thereby prevening bogus product ids from being added to the cart. | |
131 | SUGGEST | Should use one consistent of store_url or store_path for both redirection code of carts_controller and functional test of carts_controller. | 2010-04-20 | Actually, there is a reason why it is done this way, and the next beta will include an explanation from DHH. Short version: use _url for redirect, and _path for link. | |
132 | ERROR | Missing total_price function for LineItem model class LineItem < ActiveRecord::Base def total_price | 2010-04-20 | ||
97 | ERROR | class ProductTest < ActiveSupport::TestCase Should read: | 2010-04-20 | ||
132 | ERROR | I do not think that we should use instance var @line_items here, instead we should change it to line_items. def total_price
| 2010-04-20 | ||
64 | TYPO | 3rd Paragraph, 3rd line : ‘modeule’ should be ‘module’ | 2010-04-20 | ||
142 | TYPO | In the second code block, missing the change indicator triangle for the format.js line | 2010-04-20 | ||
143 | TYPO | The first troubleshooting hint is ‘Did you delete the old create.html.erb file’. I can’t see where it was created earlier. | 2010-04-20 | ||
147 | SUGGEST | I’d be great if you could explain when to use | 2010-04-21 | This is a case where I shouldn't have used the instance variable, and that will be fixed in the next beta. The discussion as to why appears on page 177 in the current beta. | |
73 | TYPO | In the gray box, ‘A “magic” commands worth knowing…’, “commands” should be “command”. | 2010-04-20 | ||
40 | SUGGEST | Re: Bullet #5, “Rails processes this template through Erubis,…” ERubis is only mentioned this once, other than the Rails dependency list. The rest of the book only talks about Erb (ie p. 38), so the mention of ERubis with no explanation was surprising. Would something like “ERubis (a fast Erb engine)” be good here? | 2010-04-20 | Switched to simply ERb. | |
149 | ERROR | In the source file, I found depot_o but starting from page 149 the source code skip depot_o straight to depot_p? So isn’t there any depot_o? | 2010-04-25 | ||
151 | OK | This bug is similar to #42843. Again, does Tests rules follow the same rule store_path for link and store_url for redirect? assert_redirected_to store_path | 2010-05-03 | ||
156 | SUGGEST | I think newbies would ask why we have ‘return’ line in controllers/orders_controller.rb. | 2010-04-24 | ||
83 | OK | depot_b/app/views/layouts/application.html.erb should be | 2010-04-22 | Are you sure you are running beta3? This changed from Rails 3.0.0.beta2 to beta3. | |
163 | ERROR | In the line_item.rb source code of the end of 163 and beginning of 164, if I understand the context correctly, the GREEN ARROW should point at line belongs_to :order instead to show this line is newly inserted and relevant to the whole context of order and line_item association. | 2010-04-24 | ||
165 | ERROR | Figure 12.3 does not reflect the code. It’s seems to be the one of Rails book 3. + There is no CSS rules for #errorExplanation in our depot.css | 2010-04-24 | ||
159 | ERROR | Missing CSS style for #errorExplanation, #errorExplanation h2, #errorExplanation ul li, .fieldWithErrors | 2010-04-24 | ||
83 | SUGGEST | In page 83, you’ve already given the source code of application.html.erb, I think we don’t have to repeat the source code in the beginning of page 84. | 2010-04-23 | ||
106 | ERROR | In the whole book makes no reference to application.css file so I believe we do not need the line <%= stylesheet_link_tag “application” %> in application.html.erb at all. | 2010-04-22 | ||
106 | SUGGEST | I am not sure if this is a mistake or not but the source no longer use the scaffold.css as indicated in the line <%= stylesheet_link_tag “depot”, :media => “all” %> so I think we should tell readers to remove scaffold.css. | 2010-04-23 | Actually, beta three changed from application.css to scaffold.css, and this example needs to be updated. | |
165 | ERROR | page[:notice].hide for create.js.rjs does not work. The notice has only CSS class and lacks HTML ID. | 2010-04-24 | ||
167 | ERROR | Same bug with #42870, both code refer to notice div with ID=“notice”. I think the fix would be add ID to div notice… | 2010-04-24 | ||
167 | ERROR | Missing routes for who_bought function resources :products do | 2010-04-25 | ||
0 | ERROR | Product model has duplication of line has_many :line_items from depot_p onward | 2010-04-21 | ||
169 | ERROR | After adding the routes for who_bought, The atom curl part is using wrong uri, it’s supposed be /products/3/who_bought.atom And to make it work, we need to modify the Product model to have: has_many :orders, :through => :line_items | 2010-04-24 | ||
163 | SUGGEST | Lack explanation on the usage of :touch => true syntax. | 2010-04-24 | Removed the use of :touch | |
0 | SUGGEST | For consistency, every iteration should have show git commit command. | 2010-05-05 | I'm concerned that that would end up being repetitive. I've added a reminder in chapter 8 as well as a pointer to chapter 16 where additional git functionality will be explored. | |
82 | TYPO | The word “download” is missing from: “…, you might want to the file fom the sample code available online.” | 2010-04-22 | ||
162 | ERROR | At this iteration, rake test still fail with 2 failures: 1) Failure: 2) Failure: They are both due to our Order fixture is bad. here is my example fixture that pass the test one: | 2010-04-25 | ||
51 | TYPO | “and will seeing and modifying” should be “and will be seeing and modifying” | 2010-04-22 | ||
51 | TYPO | “start with the Product Controller on Section 8.1,” should be “starting with the Product Controller in Section 8.1” (note two changes) | 2010-04-22 | ||
52 | TYPO | “(and for some you,” should be “(and for some of you,” | 2010-04-22 | ||
160 | OK | Why don’t we add Order’s validation for email format? It’s very common that beginners will bump into such validation. | 2010-11-10 | ||
158 | ERROR | It’s seems to me that the View code for new order form should be in _form.html.erb partial NOT new.html.erb. | 2010-04-24 | ||
163 | SUGGEST | Why do we have to set line_item.cart_id to nil? item.cart_id = nil | 2010-04-24 | So that the the line item doesn't get destroyed when the cart gets destroyed. This will be explained in the next beta. | |
163 | ERROR | The same as #42840, but I think the association deceleration should be on page 163 | 2010-04-24 | ||
145 | SUGGEST | There is no change in the cart.rb code. We are already returning the LineItem object from the original code we created on page 123 | 2010-04-23 | ||
146 | TYPO | the create.js.rjs code block is missing the change indicator triangle for the code | 2010-04-23 | ||
147 | OK | the create.js.rjs code block has 2 change indicator triangles when only 1 is needed | 2010-05-03 | The blank line is also new | |
149 | TYPO | the carts_controller code example doesn’t remove the message from the flash as the text above it suggests | 2010-04-24 | ||
9 | TYPO | Looks like this sentence was rewritten: “In the process, Rails has become mainstream, | 2010-04-22 | ||
93 | TYPO | Super minor nit: The book has “ls test/unit” printing “product_test.rb”; I got “helpers product_test.rb” (using Rails 3.0.0.beta3). | 2010-04-23 | ||
53 | TYPO | “And object is a combination of state” should be “An object…” | 2010-04-23 | ||
95 | ERROR | In the “image url” test, the second argument to both asserts might be a leftover from code copied from another test: The first assert has the message argument “product.errors.full_messages,” which does not indicate which name caused the failure. The second assert has the message argument “saving #{name}”, but the test is not saving anything. | 2010-04-23 | ||
47 | TYPO | Para 3, last sentence: | 2010-04-23 | ||
100 | TYPO | the git command, git commit -a -m “Validation!”, returns the following error: -bash: !": event not found The solution seems to either remove “!” or put it immediately after the second double quotes (first time using git, so I’m not sure about the meaning of the returned message…event? what event?) | 2010-04-23 | Seems to work better with single quotes. | |
49 | TYPO | First code example should probably show $ with the amount. So it should be as follows: order = Order.find(1) puts | 2010-04-23 | ||
52 | SUGGEST | Maybe not errata - but suggested for voice and to fix one typo: Instead of: How about: | 2010-04-23 | ||
54 | TYPO | In the description of method calls - should be plural form: Should be: Parentheses generally are optional in method calls. Ideally reordered to be: “Parentheses are generally optional in method calls.” | 2010-04-23 | ||
97 | ERROR | The definition of “class ProductTest…” depicts it as a complete, three-line definition, but actually the student is adding a line to an existing (and by now pretty beefy) class. The “this line added/changed” icon would be good here. | 2010-04-24 | ||
116 | TYPO | A hook method is a method that Rails calls automatically at a tiven point in an object’s life. tiven should read given | 2010-04-24 | ||
103 | TYPO | In the sentence “Let’s simply things for the user…”, the word “simply” should be “simplify” | 2010-04-24 | ||
118 | TYPO | at a tiven point => at a given point ? | 2010-04-24 | ||
102 | TYPO | “we will also need compliment” is missing the word “to.” | 2010-04-24 | ||
103 | TYPO | In “We’ll leave these lines along,” “along” should be “alone.” | 2010-04-24 | ||
109 | SUGGEST | “rake test” actually fails validation if the student writes the Playtime code for the previous chapter to add validation on title length >= 10 characters. Tests such as test_product_is_not_valid_without_a_unique_title fail because the the title of the product fixture, Title One, is < 10. To avoid possible confusion, you may consider replacing the title with something longer. | 2010-05-08 | ||
59 | OK | I’m baffled by the two examples of blocks appearing after calls to methods: greet { puts “Hi” } and verbose_greet(“Dave”, “loyal customer”) { puts “Hi” } These functions are never defined, so the examples and the proceeding explanation about “yield” are just confusing. I would strongly recommend defining greet and verbose_greet, with meaningful yield functionality. | 2010-11-10 | ||
117 | ERROR | I might be wrong, as I haven’t run it yet, but | 2010-07-24 | Explained that you can pass in product as rails will extract the id. | |
111 | SUGGEST | The description of the assert_select functional test reads: “So the first select test looks for an element named a that is contained in an element with an id with a value of side which is contained with an element with an id with a value of columns.” It should probably read (changed a ‘with’ to ‘within’): “So the first select test looks for an element named a that is contained in an element with an id with a value of side which is contained within an element with an id with a value of columns.” | 2010-04-25 | ||
65 | TYPO | At the top of page - in the sentence “like optional parenthesis and braces, contribute to the overall readability and easy of authoring.” 1. ‘parenthesis’ should be plural ‘parentheses’ | 2010-04-27 | ||
66 | TYPO | in description of lambda: “used in on page 222”. Remove “in”. | 2010-04-27 | ||
9 | TYPO | “therefore attracted a more diverse set of developers have been attracted to the framework” — duplicate predicate | 2010-04-25 | ||
24 | ERROR | I found it very helpful to have irb and sqlite3 (the command-line client) available. I think you should add these 2 packages to the list of Ubuntu packages that users should install. | 2010-05-01 | ||
152 | TYPO | Under what we just did section: Should read: | 2010-04-27 | ||
23 | TYPO | I would suggest to introduce the using of rvm Ruby Version Manager for Mac OS X, specially using Named Gem Sets for rails 3 | 2010-05-05 | I've added it to the todo list for part 3. I'm a big fan of rvm, and use it extensively myself on both Linux and OSX. However: my experience is that it is still evolving rapidly, and beyond the basics needed to get up and running quickly. | |
29 | SUGGEST | Maybe mention RubyMine JetBrains Rails IDE will be worth | 2010-04-27 | ||
30 | OK | Mention railsapi.com as an option for online and offline api documentation maybe will be nice | 2010-07-24 | ||
33 | OK | Maybe here is much better introduce bundler for install the Required Gems rather to use in page 22 gem install sqlite3-ruby | 2010-05-05 | My feeling is that once you are up and running, bundler is the way to go, but on initial install it represents one more thing to debug and may possibly obscure the real error. | |
35 | OK | I do not want to sound purist, but the “Hello World” demo app is almost the same as First Edition. Since REST architecture adoption for Rails Apps seems to me that Demo should be rewritten from scratch to be RESTful and showing better the current Rails practices. Maybe a good idea will be to have a i18n “Hello World” using a RESTful architecture and TDD o even better BDD. Also for beginners will be better to have the first Rails contact using the best practices. Maybe showing also the use of git for VCS | 2010-05-05 | The primary purpose of this application is an installation verification test. | |
178 | SUGGEST | Provide explanation on self.class and class << self syntax. | 2010-11-10 | ||
47 | OK | Maybe the best way to express the URL is my.url/products/2/line_items sending a POST to the nested resource line_items | 2010-11-10 | ||
182 | ERROR | the <%= f.error_messages %> doesn’t display error messages anymore | 2010-04-27 | ||
182 | ERROR | Should not hard code button caption in <%= f.submit “Add User”, :class => “submit” %> because if you do, when you edit a username, the button still shows ‘Add User’ instead of ‘Update User’. The fix is trivial, use <%= f.submit %> | 2010-05-01 | ||
60 | TYPO | the sentence “to pass a Proc as a block” could be confusing for beginners because Proc has been not defined yet. Maybe an explanation about Closures and explaining that Blocks are not objects, but they can be converted into objects of class Proc will clarify this. | 2010-05-05 | Removed the mention of the word "Proc" as it isn't necessary to the understanding of the Rails. | |
183 | ERROR | For @input_attributes, should we use symbol instead of string? | 2010-07-24 | ||
66 | OK | Because relies in Ruby Metaprogramming maybe will be good to have a section about definition as “Metaprogramming is writing code that manipulates language constructs at runtime” explaining briefly open classes, the method lookup, self, and method_missing | 2010-05-05 | There certainly is a lot to Ruby that this brief introduction doesn't cover, but none of the above is directly related to the tasks discussed in the book. Except self, which is covered on page 61. | |
69 | OK | Why not use User Stories, Features and Scenarios rather than Use Cases? That will allow also to introduce practices as TDD/BDD from the beginning easily IMHO | 2010-05-03 | The intent of part II is to introduce developers to Rails as it exists. Part III will describe other alternatives, such as Cucumber and RSpec. | |
70 | OK | Maybe will be worth to mention tools for sketching web sites as DENIM from University of Washington dub.washington.edu:2007/denim/ | 2010-05-11 | ||
96 | OK | Maybe will be worth a discussion regarding fixture shortcomings because they are external dependencies which can make tests brittle and difficult to read. And mention their replacement using Test Data Builders which give us a centralized mechanism we can use to construct objects in code examples, allowing the test examples to be very explicit about what is needed (or not needed) for a particular behavior. Without to scan through multiple files to understand an example. | 2010-05-05 | The purpose of Part II is to document features of Rails, not to criticize them or to suggest alternative. | |
153 | SUGGEST | I received undefined method when using the suggested form_remote_tag in the first playtime task. I got it to work using form_for with the :remote => true parameter. | 2010-04-27 | ||
117 | TYPO | The text reads: I think it should be: | 2010-05-01 | ||
118 | TYPO | Text reads: I think it should be: I’m only reading the chapter 9. (I don’t have the full book) or the beta version. | 2010-04-27 | ||
114 | OK | We can argue based on the responsibilities for each component that the method “find_or_create_cart” should be defined in the Cart Model as a class method rather than a private method for the ApplicationController. The session[:cart_id] could be a parameter for the Cart.find_or_create. This will be more expressive regarding the intention | 2010-05-01 | That would violate MVC: sessions are a controller concern. | |
116 | TYPO | Once this decision is made, the rest follow => should this be ‘the rest follows’ or ‘follows on’ ? | 2010-05-01 | ||
119 | ERROR | Before editing carts/show.html.erb “Line item was successfully created.” will appear twice
<%= notice %> appears at the top of default view created and there is also a call to display the notice in the application layout | 2010-05-08 | ||
124 | SUGGEST | For discussion will be rather than using “LineItem.where(:cart_id=>cart).group(:product_id).sum(:quantity)” use “cart.line_items.group(:product_id).sum(:quantity)” also for the “LineItem.delete_all :cart_id=>cart, :product_id=>product_id” replace with “cart.line_items.delete_all :product_id=>product_id” | 2010-05-01 | ||
89 | OK | Not sure why, but “validates” does not work. “validate” does. | 2010-05-01 | I've tested the code, and validates is correct: \n \nhttps://rails.lighthouseapp.com/projects/8994/tickets/3058-patch-sexy-validations | |
150 | TYPO | Since this error represent the majority of the problems reported => Since this error represents the majority of problems reported | 2010-05-01 | ||
171 | TYPO | Will this in place => With this in place | 2010-05-01 | ||
171 | SUGGEST | Should the line bundle install be given the same formatting as other command line instructions eg. depot> bundle install | 2010-11-10 | ||
51 | SUGGEST | Drop the discussion whether Erb is good or not. Calling people who don’t agree with you ‘purists’ and dismissing their arguments is bad form in my view. | 2010-05-01 | Removed 'purist', added prose suggesting that code in views is not something that should be overdone. | |
93 | SUGGEST | I’ve been using RSpec the last couple of years, so I might be missing something, but I don’t recognize the ‘test … do’ format. Looking at the web docs for Test::Unit it still uses ‘def testXYZ’. Perhaps point that out. Also - RSpec is one reason not to use Test::Unit as an answer to the question “and why wouldn’t we be” | 2010-05-07 | ||
50 | ERROR | “the Rails views can extract and format errors with just a single line of code” — not true anymore, the methods got pulled out into the dynamic_form plugin. | 2010-05-01 | ||
53 | TYPO | I believe “Welcome to the Ruby community.” should end in an exclamation mark (!) | 2010-05-01 | ||
97 | TYPO | It should read ‘:products’, not ‘:product’ class ProductTest < ActiveSupport::TestCase | 2010-05-05 | ||
114 | OK | I was seeing multiple carts being created until I modified the “create” method of CartsController, which was created by the scaffolding. def create Turned into: def create | 2010-06-28 | Can't reproduce | |
39 | TYPO | Maybe mentioning that are alternatives for Erb will worth. You can use the excellent ruby-toolbox.com/categories/template_languages.html | 2010-05-05 | Part II is for describing what is included in Rails. Part III is for replacement parts. I've added this to the list of things to cover in Part III. | |
52 | OK | Mention than the current best practice for controllers is to have a RESTful architecture. Maybe explaining here about the uniform interface, the resources, http methods, nesting resources, the formats to respond, and routes> I know this imply profound changes in the section, but REST has several years in the mainstream of RoR then IMHO it is imperative to have in this book. Restful is only mention on page 15. I know that you have an stub in page 235 for Rails Concepts, but I insist that an earlier introduction about REST architecture is a must | 2010-07-24 | This book is very intentionally layered... just enough theory to provide needed context, then a lot of actual use, finally followed by a description of the actual components, with the theory behind them. | |
53 | OK | Well, it is true that Ruby Is an Object-Oriented Language but will be worth to mention that is multi-paradigm including functional, object oriented, imperative and reflective. It also has a dynamic type system and automatic memory management. I know this is a gentle introduction for beginners but the functional and reflective paradigms are important for some RoR constructs, then a mention about this will be worth IMHO | 2010-05-11 | I'm just trying to cover enough Ruby to make the examples which are contained in the book comprehensible. If you see a specific feature of Ruby that is actually used in the book that requires explanation, please create specific errata on such features. | |
69 | OK | I will insist that IMHO the intent for the section and the spirit for an Agile Software Development book is more related with User Stories rather than Use Cases. As you know Use Cases have an special connotation since Ivar Jacobson work and refined as a technique specially in the work of Alistair Cockburn. As it is mentioned in wikipedia a use case in software engineering and systems engineering is a description of a system’s behavior as it responds to a request that originates from outside of that system. In other words, a use case describes “who” can do “what” with the system in question. The use case technique is used to capture a system’s behavioral requirements by detailing scenario-driven threads through the functional requirements.
Now in the BDD practices they are using Feature as a high level requirement expressed from the perspective of a person or another computer using the system. Those are similar an a User Story but additionally include automated scenarios that serve as acceptance criteria, expressing each feature in the Connextra Format and their scenarios as steps for: Given, When, Then I am sure you are aware about all these an even more, but my point is that the book should express or mention this. | 2010-05-11 | Let's continue this discussion on the forums: http://forums.pragprog.com/forums/148/topics/4372 | |
70 | OK | Maybe mention the Paper prototyping method from human–computer interaction will be worth | 2010-07-26 | ||
78 | ERROR | The output from rails server is outdated, as it is mentioned on page 22 RoR requires Ruby version 1.8.7 and this output shown [2008-03-27 11:54:55] INFO ruby 1.8.6 (2007-09-24) [i486-linux] | 2010-05-05 | ||
81 | OK | Because this book will be read also by beginners IMHO, best practices should be presented and enforced then rather to put the Unit Testing in Iteration B2 I will suggest to put in iteration A2. In the same line is not clear for a beginner how do you transitioned from the User Story or Use Cases ;-) to the implementation. | 2010-05-11 | Doing test first development would nearly double the size of the book, and would dilute the focus on Rails. If you look closely, we are only writing tests for a fraction of the functionality, and fixing only slightly more than absolutely necessary in the generated tests. At the end of part II, I plan to explain that while this exposes you to the necessary concepts of testing as provided by the Rails framework (namely: unit, functional, and integration testing), it is incomplete. | |
89 | OK | Again, maybe will be worth to write the unit test before than the validation. This to enforce the TDD/BDD cycle as a recommended practice | 2010-05-05 | See #43067 | |
94 | SUGGEST | To be consistent with the full test change assert !product.valid? to assert product.invalid? | 2010-05-05 | ||
107 | SUGGEST | Maybe will be useful put a Ruby tip for yield to page 59 | 2010-05-05 | ||
114 | SUGGEST | The find_or_create_cart name IMHO is not appropriate for the domain of the application, I’ll suggest current_cart which emphasizes the domain intention for the method that is to have the current_cart for the session. If the current_cart does not exist creates a new cart if the cart exist returns the current cart after finding it by id | 2010-06-19 | ||
115 | SUGGEST | In this stage the before_destroy :ensure_not_referenced_by_any_order filter could be renamed to before_destroy :ensure_not_referenced_by_any_line_items to reflect better the current intention. I know that later the Order domain objet will be included and defined as a set of line_items along with details of the purchase transaction. But that is not defined yet. And will be good to refactor the filter to renamed once the Order domain object will be included in the application | 2010-05-07 | ||
123 | OK | IMHO the line current_item = line_items.where(:product_id => product_id).first | 2010-05-08 | That hasn't been explained yet | |
110 | TYPO | “provides” should be “provided” | 2010-05-05 | ||
149 | SUGGEST | Maybe worth to put a Ruby tip call for &block notation to page 59 | 2010-05-07 | ||
152 | OK | The Test First in TDD/BDD actually are more about to define the desired behavior written the failing test using The Code You Wish You Had this will provide you with an emerging design. Usually this is better if you use an outside-in approach where Business Value drives the development. Then you code The Code You Wish You Had to pass the test/scenarios and refactor and pass the test/scenarios. | 2010-07-24 | ||
156 | SUGGEST | If you follow my previous suggestion for renaming find_or_create_cart to current_cart the line of code if find_or_create_cart.line_items.empty? will be more terse if current_cart.line_items.empty? | 2010-06-25 | ||
173 | OK | As a suggestion for readers maybe will be worth to mention gems populator and faker | 2010-07-24 | ||
209 | OK | Maybe mention the main gems/plugins for Rails Authentication ruby-toolbox.com/categories/rails_authentication.html will be worth | 2010-07-24 | ||
231 | OK | For the deployment of the depot application are you considering to mention other Deployment Automation tools? Vlad, moonshine, etc. | 2010-07-25 | ||
235 | OK | You should open the scope for TDD covering also BDD | 2010-07-25 | ||
235 | ERROR | You are mentioning CI (Continuous Integration) in both sections. This is intentional? | 2010-05-08 | ||
142 | TYPO | Typo is add is a call What we are going to do is add is a call to respond_to telling it that we want to respond with a format of .js. | 2010-05-07 | ||
82 | OK | I downloaded all source code examples for the book and when I go to run “rake db:migrate” in depot_a or depot_b (at least, I haven’t tried others yet) I get: (in /tmp/depot_b) I compared your Rakefiles to one that I generate using Rails3.0.0beta3 and I noticed that you are missing the following two lines from your Rakefile: require ‘rake/testtask’ Those two lines appear right below “require ‘rake’” I don’t know if I have a special environment or if you have outdated Rakefiles. Just wanted to notify you. Awesome book! Thanks! | 2010-05-07 | I'm actually developing using the latest (unreleased) Rails. This will work itself out as new betas of Rails are released. | |
122 | TYPO | “adding a one or more columns” should read “adding one or more columns” in the sentence that starts: | 2010-05-07 | ||
123 | OK | Tighter code for add_product: current_item = line_items.where(:product_id => product_id).first Also, the code might be more intuitive and prettier to use product instead of product_id. | 2010-05-08 | While that code is unquestionably tighter, I believe it is more difficult for somebody new to Ruby to understand. | |
127 | OK | The error screenshot is misleading. In production, the error screen is much nicer. I think getting an error screen in response to a user-type invalid URL is a perfectly legitimate response. I don’t think you should encourage people to litter their code with validations like this, it’ll just bloat apps and make coding less fun. Also, if you’re really keen on handling this error, I think it’s more robust to replace Cart.find with Cart.where(:id => params[:id]).first and do an if based on that value (it’ll be nil if the record doesn’t exist). This way you’re safe no matter what exception gets raised. | 2010-11-10 | ||
131 | OK | Regarding the “David Says…” bubble — sounds like redirect_to should raise an error if the path isn’t a full URI (perhaps check that ‘:’ occurs before ‘/’?). Why not file a bug and get this fixed, then describe it in the context of handling the exception? | 2010-05-08 | That likely would break code that works, even if it is the code is technically wrong. | |
143 | ERROR | :partial and :object are getting out of style in Rails 3 as far as I’ve seen. How about replacing the code with page.replace_html(‘cart’ , render(‘carts/cart’ , :cart => @cart)) | 2010-05-07 | ||
143 | ERROR | Gah, sorry, I wasn’t thinking. This would be even better: | 2010-05-07 | ||
157 | TYPO | You mean <%= form_for ? | 2010-05-07 | ||
47 | TYPO | Remove the word ‘for’ from the following line. “See Figure 3.1 for to see how the three concepts fit together.” | 2010-05-07 | ||
64 | TYPO | 2nd paragraph, 2nd line : “name” should be “named”. | 2010-05-07 | ||
93 | TYPO | Top paragraph; “What need to do more than that” I believe should be “We need to do more than that” | 2010-05-07 | ||
54 | TYPO | Extra period | 2010-05-07 | ||
81 | TYPO | 4th Paragraph, 3rd Line : “The” should be “They”. | 2010-05-07 | ||
146 | TYPO | bottom of the page. and no download link. <%= button_to “Empty cart” , :action => :empty_cart %> | 2010-05-08 | ||
95 | TYPO | The looped block behind the bad and new array is exactly the same piece of code. Doesn’t look so DRY :-). | 2010-05-07 | One test for valid, and the other for invalid; but you are right this can be improved. | |
112 | ERROR | The last item in “Playtime” suggests writing function tests for the product maintenance application, placing the tests in store_controller_test.rb. Should the tests be placed in products_controller_test.rb instead? | 2010-05-08 | ||
119 | OK | “<% for item in | 2010-05-08 | This early in the book, I'm trying to keep with things that might not look so foreign to people new to Ruby. | |
114 | OK | Says: " This makes this method only available to other controllers, and in particular it prevents Rails from ever making it available as an action on the controller." Should say “as an action on the view”? | 2010-05-12 | ||
82 | ERROR | I received a HTTP 403 error when trying to download images as suggested from this link: media.pragprog.com/titles/rails4/code/depot_b/public/images/ | 2010-05-12 | Will fix in the next beta. For now, you can find the images here: \n \nhttp://media.pragprog.com/titles/rails4/code/depot_c/public/images/ | |
202 | TYPO | Second to last paragraph: | 2010-05-12 | ||
35 | TYPO | Bottom of page Pretty minimal, eh? SayController is an class … Pretty minimal, eh? SayController is a class … | 2010-05-12 | ||
106 | TYPO | …layout application.html.erb, it will the layout used… Should perhaps include “be” as in “…it will be the layout used”… | 2010-05-12 | ||
111 | SUGGEST | I assume the fixtures shown here will be updated? As they are now, the title of the first two items are not unique. | 2010-07-24 | Added a note that neither validation nor functional tests directly affect pre-existing data, whether such data exists in the database or exists in fixtures. | |
237 | SUGGEST | In the deployment section, the production database is created in three steps: the mysql create database command, rake db:migrate, and rake db:seed. This makes sense for a first-time deployment, because it lets you see if you messed something up in any of the steps. However, Rails provides a Rake task db:setup, which combines the database creation, migration, and seeding steps into one step. It also uses the schema dump to create the schema rather than running the migrations in sequence, which I believe is the Rails-recommended way of creating a new database. This is probably worth mentioning. | 2010-05-17 | ||
237 | SUGGEST | You suggest using the mysql root user for the production database. This is not a best practice, as if there are any SQL injection bugs in the app an attacker will be able to gain full control of the database. User management in mysql is a pain, but it would be helpful to explain how to create a non-superuser and grant it permissions on the database. | 2010-05-17 | ||
87 | TYPO | “[…]This may not seem very exiting at this point, but it does mean that you are more free to experiment.[…] ”exiting" should be “exciting” | 2010-05-12 | ||
64 | OK | 3rd par. 3rd line ActiveRecord modeule | 2010-05-12 | Fixed in beta 2 | |
69 | TYPO | 2nd par - 2nd line tests will ensure that application | 2010-05-12 | ||
83 | OK | <%= stylesheet_link_tag :all, ‘depot’ %> Should read <%= stylesheet_link_tag :all %> Otherwise it looks exactly the same as on the next page… | 2010-05-14 | Fixed in beta 2 | |
105 | SUGGEST | “Note the use of the raw method for the description. This allows us to add HTML stylings to make the descriptions more interesting for our customers. (Note: this decision opens a potential security hole, but because product descriptions are created by people who work for our company, we think that the risk is minimal.)” I would suggest you explain that ‘raw’ bypasses the default behavior of encoding the output, a common defense against XSS attacks. Then footnote to a site such as OWASP to let the reader study XSS attacks and security in general. Security is a topic often neglected in programming titles. www.owasp.org/index.php/Cross-site_Scripting_%28XSS%29 | 2010-07-24 | ||
106 | OK | Routing Error to application.css, should be scaffold.css | 2010-05-14 | I can't find application.css mentioned, either on this page or in the entire book. | |
121 | ERROR | Playtime, first bullet (making book’s image invokes create action): you really should mention that “<%= javascript_include_tag :defaults %>” should be added to the layout file or :method=>:post option will never work. Being a Rails newbie, a spent about an hour on this issue… | 2010-05-25 | ||
110 | TYPO | In the section “Iteration C4: Functional Testing of Controllers”, The second sentence of the paragraph says: Remembering the our experience after we added validation logic to our model, with some trepidation we run our tests again. It seems the “the our” is a typo. Thanks, | 2010-05-16 | ||
233 | OK | Phusion also runs on nginx now and has for a while - perhaps a sidenote of some sort relating to an nginx/passenger deployment? | 2010-07-25 | ||
246 | ERROR | At the top of page 246 you print examples of how to configure the logger in Rails 3: config.logger = Logger.new(config.log_path, 10, 10.megabytes) Both of these examples will cause Rails 3 to crash/fail to load (I’m using Rails 3 beta3), it looks like this is because there is no log_path method. I’ve had a quick look but I’m not actually sure how to set this now in Rails 3. Documentation is currently ropey at best! | 2010-05-25 | This is actually changing in Rails 3. I've updated the beta, but will need to track the changes. | |
42 | TYPO | “are used , Rails applications are typically written” remove the space after “used” so the comma doesn’t stand alone. Cheers! Marc | 2010-05-16 | ||
111 | TYPO | Third paragraph: “The next line verify that there are h3 elements…” should be “verifies”. | 2010-05-16 | ||
112 | TYPO | First paragraph: “That’s a lot of verification is just a few lines of code.” Should be“… in just a few…” | 2010-05-16 | ||
127 | TYPO | ‘following page This reveals way too’ Missing a period in the last paragraph, within the snippet above. | 2010-05-16 | ||
33 | TYPO | As we’ll see later (in on page 250), -> As we’ll see later (on page 250), | 2010-05-17 | ||
38 | TYPO | See in Figure 2.3. -> See Figure 2.3. | 2010-05-16 | ||
43 | TYPO | let’s take it gently for now…. -> let’s take it gently for now… (three periods, not four—ellipses don’t need a trailing period at the end of a sentence) | 2010-05-16 | ||
105 | SUGGEST | A possible gotcha at this point … a) remind the user to rake db:seed to reload the seed data if they need to (playtime at the end of iteration A has them potentially doing a rollback which would destroy existing data). b) change the “validates :title, :length => { :minimum => 10 }” (potentially added in playtime of iteration B) to length => { :minimum => 9 } first otherwise the Debug It! book won’t be added when seeding. ;) | 2010-11-12 | I've added the reminder in the Playtime section of section A. \n \nThe plans at the moment are to replace "Debug It!" with "Rails Test Prescriptions". | |
109 | TYPO | Second last line of section 8.3 reads “writing tests for all this new function” but should perhaps read “writing tests for all this new functionality”? | 2010-05-25 | ||
111 | TYPO | “The next three lines verify our product are displayed” should be “The next three lines verify our products are displayed” | 2010-05-25 | ||
112 | TYPO | In What We Just Did, item 3 says “Add a class method to the Product model to provide a list of items for sale.”, but in this version we used a default_scope instead. Whilst it’s essentially the same thing, this may be a little confusing. ;) | 2010-05-25 | ||
112 | TYPO | Last bullet point says “the end of an iterations” but should be “the end of an iteration” | 2010-05-25 | ||
132 | TYPO | Under David Says: “…but it won’t valid according to spec. ” should be “…but it won’t be valid according to spec.” | 2010-05-25 | ||
79 | OK | The code-example in the middle of the page seems to be wrong: CS | 2010-05-25 | Are you sure that you are running Rails beta 3? What you are describing was the way this was done in Rails 2, and continues (for the moment) to work in Rails 3, but the intent of the Rails team is to deprecate those methods in favor of the validates method. | |
89 | OK | The formatting of the source-code at the bottom of page 89 is broken | 2010-11-10 | ||
58 | TYPO | Ruby also provides a number of ways to make decisions which affect the repetition and order of in which methods are invoked. | 2010-05-25 | ||
63 | TYPO | In YAML, indentation is important, so this defines development as having set of four key/value pairs, separated by colons. | 2010-05-25 | ||
69 | TYPO | “Rails not only enables the creation of such tests, actually provides you with…” | 2010-05-25 | ||
85 | TYPO | “Using this parameter is this way…” | 2010-05-25 | ||
149 | OK | When I followed the example, the code snippet below <%= render(:partial => “cart”, :object => @cart) %> resulted in the following error: ActionView::Template::Error (Missing partial store/cart with {:locale=>[:en, :en], :handlers=>[:erb, :builder, :rjs, :rhtml, :rxml], :formats=>[:html]} in view paths " … | 2010-06-28 | This would indicate that app/views/carts/_cart.html.erb is not present. This file was created on page 139. | |
148 | OK | Has the “total_items” any use besides it’s use in the “blenddown” call? Unless it hasn’t you could also use the @cart.line_items.count method. | 2010-06-28 | That wouldn't take into account the quantity. What would work is @cart.line_items.sum(:quantity). | |
24 | ERROR | The details for installation of rails on the mac do not indicate the correct way to install rails 3.0. This results in the rest of the book not working as expected. the command: sudo gem update rails should read: sudo gem update rails —pre otherwise you get the latest stable version of rails, not the one in this book. Obviously if 3.0 is stable for the release things are correct, but for current users this is a problem. | 2010-05-25 | ||
110 | TYPO | “Remembering the our experience after we added validation…” | 2010-05-25 | ||
111 | TYPO | The next three lines verify our product are displayed. | 2010-05-25 | ||
106 | ERROR | application.html.erb should also have: | 2010-05-25 | ||
112 | TYPO | That’s a lot of verification is just a few lines of code. | 2010-05-25 | ||
112 | TYPO | Bullet points in “What We Just Did” section are in various different tenses. | 2010-05-25 | ||
112 | TYPO | Just a reminder, the end of an iterations is a good time to save your work using git. | 2010-05-25 | ||
119 | OK | I think “ | 2010-05-25 | No, it is meant to use the local variable assigned on the previous line: "product = Product.find(params[:product_id])" | |
206 | ERROR | It looks like you have wrong listing of the application layout for iteration I4: it’s admin links what should be added here, not l18n features. | 2010-06-27 | ||
162 | ERROR | At the end of this page it talks about altering the fixtures to accommodate changes made to validation in an order, however the listing is for line_items, which are also listed later (pg165), I suspect this listing wants to be for the orders fixtures, otherwise tests will fail here.. | 2010-06-26 | ||
172 | ERROR | When working through the examples, and getting to the curl to retrieve the atom feed for orders, I discovered an omission. The code returns errors about products not containing orders. It would seem that the necessary has_many code has not been mentioned. Looking at the example code downloads this should be added to Product.. This means that about page 165 the has_many relationships need adding in for Products | 2010-06-26 | ||
260 | TYPO | Top of the page: “…you will need to add gem RedCloth (note: case is significant) to your Gemfile, and run gem install.” - do you mean “bundle install” instead of “gem install”? | 2010-06-27 | ||
174 | OK | I might have missed something, but the paginate code was throwing an error as not existing until I restarted the server. If this is needed, the page doesn’t mention the need to stop the server and restart after installing the bundle | 2010-07-24 | This should not be necessary | |
183 | ERROR | Didn’t you mean to show an example of html email here and not the text email again? Also, aren’t the templates named “order_received.text.erb” and “order_received.html.erb” instead of “order_received.text.plain.erb” and “order_received.text.html.erb” on line 7? An example of the html template could be the following (with some silly formatting to be easily tell we’re getting html email):
| 2010-06-27 | ||
208 | ERROR | app/views/layouts/application.html.erb shown on this page has a lot of the i18n stuff already in it, when we haven’t learned about it until the next chapter… So it doesn’t match the file we’ve built up till now when working through the book. | 2010-06-27 | ||
94 | TYPO | Typo: the last sentence of the first paragraph (immediately before the heading for section 7.2) should read “As for now, it is time for us to write some unit tests.”. | 2010-06-19 | ||
32 | ERROR | Hi, First off, thanks for the hard work on the Fourth Edition :-) The section ‘Creating Your Own Rails API Documentation’ does not apply because we are not using Instant Rails, so at the very least please amend. Unfortunately, when I followed the instructions I got loads of errors and the API was not produced. Warmest regards, Jeff Lawson | 2010-06-19 | Removed mention of Instant Rails, but running rake doc:rails from the command line is the correct way to produce documentation. If you could, let me know what the errors you are getting by posting to the forums, and I will see if I can help further. \n \nhttp://forums.pragprog.com/forums/148 | |
219 | ERROR | Near the end of the page when you say “At this point, we can see in Figure 15.3 the some actual translated text appearing in our browser window.” apart from the grammar error (i.e. “the some actual”), this isn’t true. If following along, there will be exceptions thrown at this point and the /es page won’t render because of currency conversions in number_to_currency. /en renders fine, but /es fails. If you put in the currency localisation found later (i.e. the number: section for the yml files found on pages 222-223) then it will work. | 2010-11-12 | corrected the grammatical error, still trying to reproduce the problem reported. | |
220 | SUGGEST | On the page you say “Note that since title_html ends in the characters _html, we are free to use HTML entity names for characters that do not appear on our keyboard. If we did not | 2010-11-13 | ||
227 | ERROR | The changes for _form.html.erb shown here were already shown on page 225. They should probably be removed from the version on p. 225 to give the expected results in the figures. | 2010-11-13 | ||
229 | OK | After fixing up the error strings for :es, the English ones were no longer correct, I had to add a lot of the activerecord: and errors: sections into en.yml also for the English path. | 2010-11-13 | ||
229 | OK | forgot to paste in the en.yml changes I made: activerecord: errors: | 2010-11-13 | ||
227 | SUGGEST | The figure doesn’t match what the code says. The whole error box looks different (i.e. lacks the ‘title bar’) when using the following in _form.html.erb: so maybe update the figure, or modify the template to match it? | 2010-07-25 | ||
229 | SUGGEST | also, the payment methods aren’t localized, not sure how much work it would be to do this. So it might’ve been skipped on purpose. | 2010-07-25 | Added as a playtime exercise | |
180 | ERROR | The book shows source code for the mailer which is generated. This is not however correct to the code generated by rails. The command issues on this page creates the files, but their content is just stub content. This source on the page is populated already with meaningful code in relation to orders etc.. The generated code is simply generic. | 2010-06-26 | ||
185 | OK | When we run the functional tests at this point, the tests will fail for sending the order shipped email. At this point in time we have not actually defined the text and html content for shipping the emails. This isn’t actually done at all in the chapter, and the tests will not pass. | 2010-06-28 | Rails provides initial text templates, enabling the tests to pass. | |
160 | OK | the code example for _form.html.erb is: it should be | 2010-06-28 | Correct as is, needs to match: \n \nhttp://media.pragprog.com/titles/rails4/code/depot_p/public/stylesheets/scaffold.css | |
194 | SUGGEST | In the password= definition, is it neccessary to assign self.salt = …. when the function generate_salt assigns the value to self.salt? Surely this means the call should just be: if password.present? | 2010-06-27 | ||
19 | TYPO | Epub specific bug: “Ruby and Rails at the same time. the Section …” Whatever magic is making the epub version different from the PDF with respect to chapter / section linking is broken :) it’s all throughout the book, so I won’t bother reporting it any further — it’s probably all the same macro. | 2011-03-04 | ||
43 | TYPO | (At least I think it’s on page 43 of the PDF; my sony reader reports page 50 in the epub version.) epub bug, % is on a different line than > in one of the erb examples. Is there any way to tell epub readers to not split <% and <%= and %> (and others..) in the code examples? | 2011-03-02 | I'm afraid not.... | |
42 | OK | “method names are used , Rails applications” s/ , /, / | 2010-06-19 | ||
50 | TYPO | Another epub-specific bug: “|order|” has been broken across lines in the code listings on my sony reader. | 2011-03-02 | ||
63 | TYPO | “help you with your Rails coding” Missing period. | 2010-06-19 | ||
72 | SUGGEST | “be using a database—sometimes a flat file beats a database table hands down.” I’d be more willing to believe this if any of the previous three versions of this book had ever used a flat file for data storage. :) Okay, there’s plenty of yaml files around, but those aren’t very flat. And I’ve never seen one tied into a model in the application. Maybe it’s time to let this sentence go. :) | 2010-06-19 | dropped second half of the sentence. | |
77 | TYPO | The migration filename doesn’t match the cut-n-paste rails generate scaffold output. (I know you cover this in a bit, but perhaps “The one we’re interested in first is the migration*_create_products.rb” would make more sense than hard-coding the wrong datetime and version string. :) | 2010-06-19 | ||
78 | TYPO | The parenthetical statement beginning: “(If you get an error saying Address already in use” doesn’t have a close parenthesis. | 2010-06-19 | ||
89 | SUGGEST | All the validation examples are off the edge of the page on my sony reader on the epub format. | 2011-03-02 | Sorry—not much we can do about that... | |
105 | SUGGEST | I suggest describing the ‘raw’ method in more detail. Those of us coming from older versions of Rails are used to h() html-escaping everything by hand. And it got tedious. If the presence of ‘raw’ means what I think it means, it is a glorious day for RoR programmers, and a giant step in the right direction. Rails goes a very long way to remove giant classes of security bugs, and it makes sense to tout the features at every turn. (I dream of a php-free day. register_globals was just the tip of the iceberg, and Magic Quotes shows how little the php team cares about the integrity of your data..) I’d also find it useful to have a sidebar or side-helper thingy mention that for almost-trusted inputs that you could instead use markdown or any related flavor of html-generating thing that also prevents raw html from coming through. Some pointer to say “there’s middle ground between all or nothing.” | 2010-07-24 | Switched to that fabled middle ground: sanitize; and provided a pointer to the point in section 3 were this is discussed further. | |
105 | TYPO | “it will the layout used” s/will the/will be the/ | 2010-06-19 | ||
109 | TYPO | “all this new function.” s/function/functionality/ | 2010-06-19 | ||
114 | SUGGEST | “We’ve got the session stuff sorted out” It sure didn’t feel sorted out to me! :) The session object is just used without much in the way of fanfare. I think it’d be fair to put in a few sentences about where the data in the session goes between requests, its lifetime, how well you can trust the data in the session, just what kind of data is appropriate to put into the session, what needs to be revalidated after being loaded from the session… It doesn’t feel at all ‘sorted out’. :) | 2010-06-25 | Added a forward pointer to where it will be covered in depth. | |
115 | TYPO | “an Cart” Either “a Cart” or “Cart” would scan better. | 2010-06-19 | ||
116 | TYPO | “add an :product_id” Either “add a :product_id” or “add the :product_id” would scan better. (I suggest ‘the’, because symbols are singletons.) | 2010-06-19 | ||
119 | TYPO | “lets write a a trivial” s/a a/a/ | 2010-06-19 | ||
120 | TYPO | The bullet points are inconsistently capitalized and punctuated. | 2010-06-21 | ||
122 | TYPO | “adding a one or more columns” s/a // | 2010-06-19 | ||
122 | TYPO | “data type each this column from last argument.” I’m not sure how to fix this. :) | 2010-06-21 | ||
124 | TYPO | “for each the line items” s/each the/each of the/ | 2010-06-19 | ||
125 | TYPO | “greater than one, Adds new line items” s/Adds/adds/ | 2010-06-19 | ||
129 | TYPO | The text “See figure … on page … for a much more user friendly result.” is referring to the wrong figure. (In this version of the PDF, it is referring to figure 10.5 on page 134, but the figure is 10.4 on page 130. In the epub format, the name of the wrong figure is given.) | 2010-06-25 | ||
130 | ERROR | Very unsafe destroy() method in file depot_h/app/controllers/carts_controller.rb. This destroy method allows someone to destroy every single shopping cart on the system. The cart should be scoped by user. (If this is for simplicity here, PLEASE put a comment in the code along the lines of “never do this, see section …”.) | 2010-11-10 | ||
131 | TYPO | “but it won’t valid according to spec.” In the David Says… sidebar. s/won’t valid/won’t be valid/ | 2010-06-21 | ||
135 | TYPO | AJAX and Ajax are both used on this page. AJAX is also used in a section header on 150. | 2010-06-25 | ||
142 | TYPO | “Rails will look for an create template to render.” s/for an create/for a create/ | 2010-06-21 | ||
151 | OK | Something seems a bit silly about the application.html.erb snippet: <% if The whole point of hidden_div_if was to code around an empty cart. Changing the condition like this should work: hidden_div_if( | 2010-06-28 | All hidden_div_if does is set the display:none CSS property. \n \nWhat we really want to do is prevent the call to render @cart if there is no cart. | |
158 | ERROR | The figure “Names in form_for map to objects and attributes” has a form like this: <% form_for :order, :url => { :action => :save_order } do |form| %> but the code snippet has a form like this: <% form_for @order do |f| %> | 2010-06-25 | ||
164 | SUGGEST | I was very lost for most of this section, and I didn’t realize why until “All that is left is to define the relationships themselves”. The relationships are the whole point… I had trouble following along the view code and the control code because I had no idea what the data looked like. I always find the layout of data easier to understand than code. (This might be the closest I ever get to being Fred Brooks. :) Please consider moving the models towards the head of the iteration. | 2010-07-24 | ||
164 | TYPO | “And we modify the test fixture to so that” s/to/too/ | 2010-06-19 | ||
170 | TYPO | “we need to define an route” s/an route/a route/ | 2010-06-19 | ||
173 | TYPO | “(feel free” Unmatched parenthesis. | 2010-06-26 | ||
175 | TYPO | “linked it a new order model.” s/linked it a/linked it to a/ | 2010-06-26 | ||
178 | TYPO | “created an Notifier class” s/an Notifier/a Notifier/ | 2010-06-26 | ||
179 | ERROR | The text mentions “confirm.erb”, but the mail template is in order_received.text.erb. | 2010-06-26 | ||
182 | ERROR | $RAILS is used undefined in the Joe Asks sidebar. | 2010-06-26 | ||
183 | TYPO | Inconsistent capitalization between “Unit testing of models” vs “functional testing of controllers”. | 2010-06-27 | ||
188 | SUGGEST | SHA-2 should be used in place of SHA-1 for new applications. SHA-1 should only be used for interoperability with existing applications that have not yet been upgraded. Salted passwords are probably still fine with SHA-1, but this is an opportunity to learn good habits for the next decade. :) | 2010-07-24 | ||
188 | OK | “used elsewhere in the all-to-common case where” s/to/too/ | 2010-06-28 | Correct as is. | |
193 | TYPO | “let’s avoid the redirect to showing the user after either a create operation.” Suggest delete ‘either’. Could also read “after both create and update operations.” or “after either create or update operations.” | 2010-06-27 | ||
193 | OK | The @user.name is passed directly to the flash :notice without any HTML escaping. Is the flash rendered with or without HTML escaping? My guess is that the flash is rendered raw, in which case the user.name is a vector for cross-site scripting flaws. | 2010-06-27 | The notice is inserted into the view using <%= notice %>, which will HTML escape the content unless the view is modified to specify raw. | |
201 | TYPO | Missing period after “We will describe all that you can do .. routing … ” | 2010-06-26 | ||
202 | TYPO | “In our case, we’ll use a before4filter to intercept” s/before4filter/before_filter/ | 2010-06-26 | ||
202 | TYPO | “exposed to end user as an action.” s/user/users/ | 2010-06-26 | ||
208 | TYPO | “Plugins that provide a ready made solution” s/ready made/ready-made/ I thought “Plugins that…” was inelegant when I first read it, but I have no suggestions how to improve it. :) | 2010-06-26 | ||
210 | TYPO | “and we are going to have to changes the views to make use of these translations” Suggest: “have to change the views to use these translations” | 2010-06-27 | ||
212 | OK | In the internationalization section, the routes are scoped with :locale, which provides foo/en, foo/es, foo/de, etc versions, which is nice, but there’s no use of the standard HTTP header Accept-Language. Pity. If Accept-Language were used to set the locale initially, the clear majority of users would never need to set their language. (I try to keep my German sharp by reading the German wikipedia — so I’m very glad to have easy URL-based mechanisms to select between the English and German versions, so I wouldn’t want to remove the paths! :) | 2010-11-12 | ||
212 | TYPO | “but only if there is a locale value is in the params” s/value is in the/in the/ | 2010-06-27 | ||
216 | TYPO | “the some actual translated text” Suggest: “the translated text” | 2010-06-27 | ||
217 | TYPO | “Rails will also treat as HTML key names that with the name html itself.” Please revisit :) | 2010-06-27 | ||
222 | TYPO | “will will want” s/will/we/ | 2010-06-27 | ||
222 | SUGGEST | Order::PAYMENT_TYPES is left untranslated in the translated application — so Credit Card, Check, and so forth are kept. That’ll be funny for most of the world, as plenty of English speakers use Cheque, and perhaps confusing for chinese or korean or languages not derived from europe :) | 2010-07-25 | Made a playtime exercise | |
228 | SUGGEST | Please explain why the input tags in the locale form need to be hidden. The whole javascript_tag portion of the snippet is really confusing, and makes me wonder just what else will require some baffling javascript. | 2010-07-25 | ||
236 | SUGGEST | You say you’d like to cut down the active record chapter by a factor of 3 or 4. Strictly from a page count, I can understand that that’s a ton of paper :) but the in-depth view of active record in the previous books was always my favorite part. And, now that the ORM layer can be swapped out, I would like some mention of why (and maybe how — depends on the why. :) | 2010-06-27 | Next beta will contain the streamlined chapter. Mostly it was done by eliminating the reference material descriptions of each parameter, and duplication of content already covered in Depot. Feedback welcome. \n \nAlternatives will be described in a subsequent chapter. | |
241 | TYPO | “is not in the core of Rails does no mean that it isn’t” s/does no mean/does not mean/ | 2010-06-27 | ||
241 | SUGGEST | I didn’t see any reference to action caching, page caching, fragment caching, or using memcached to add object / list / tree caching. I think Rails is slow enough that caching is going to be required for anything remotely popular.. | 2010-07-25 | Caching will be covered in chapter 20. | |
241 | OK | I’ve seen a lot of references to datamapper and jquery while browsing Rails blogs. I think perhaps they could justify another page or two, to help understand why they are so popular. Thanks! | 2010-07-25 | chapter 25 will cover these | |
98 | TYPO | First sentence of third paragraph down. | 2010-06-19 | ||
34 | ERROR | The command to create a new rails app is listed as “rails demo”, but this will not work in Rails 3. You must use “rails new demo” | 2010-06-19 | ||
216 | OK | In “..aliased as I18n.t, but there also…” the t looks like it’s the wrong font? | 2010-11-12 | ||
26 | OK | You’re suggesting to use sudo gem update —system, which may make a mess in the system (i.e. interfer with distro package management) and does not work reliable. I suggest to spend an extra page on rvm and using that instead. | 2010-11-10 | My primary system is Ubuntu, and I've been successfully doing this for years. | |
211 | ERROR | When someone tries to delete an user a flash notice is set but the code to display the notice in the view is missing. At this point of the book anyone should know to display a flash but still… | 2010-11-12 | ||
208 | ERROR | It has to be page.select(“p#notice”).each as the flash notice does appear in a p-tag, not directly in the div. | 2010-06-26 | ||
209 | ERROR | I copied those files from your server but when calling the URL as mentioned in the text the app throws the following error: ActionView::Template::Error (undefined method `orders’ for # Did I miss something in the steps before or is it a real error? | 2010-06-27 | ||
111 | TYPO | Missing apostrophe on “That’s” in the sentence that begins with “Thats a reasonable beginning” | 2010-06-19 | ||
234 | TYPO | “One such tools, namely” s/tools, namely/tool,/ (okay, the ‘namely’ part is more style than typo, but it seems out of place. :) | 2010-06-27 | ||
234 | OK | The first time I’ve encountered the name “Phusion Passenger” is in the sidebar about MS Windows. I think something as fundamental as the server-based ruby interpreter should get much stronger billing than being stuck in a sidebar about one specific operating system. Further, until reading further, I had no idea what role Phusion Passenger played in the deployment, so I wasn’t sure I was even going to bother with it. It’d be nice to mention other possible deployments too. Back in the day, lighttpd with FastCGI was the preferred deployment method. Now, it seems nginx with … what? is the preferred deployment method. Apache is tried and true, but might have too many levers and knobs for its own good. I guess this far out-paces an iteration in the depot application; but I’d like to know the tradeoffs between the most popular four or five web servers, most popular three or four CGI-replacements, etc. I know all this is subject to rapid change — lighttpd was the hot new kid on the block just a few years ago, and now no-one remembers its name, because nginx is the neat new thing — but some of us old guys would like to know why the previous best deployments are no longer even mentioned.. | 2010-06-27 | The purpose of the sidebar is to state to Windows users that this chapter is not for them, and it needs to say way that is. That does mean that Phusion Passenger is mentioned first in a sidebar, which is unfortunate but necessary. \n \nThe purpose of Part II is to describe the "golden path", or the Rails Core team recommended approach. Alternatives are covered in Part III. | |
238 | OK | When suggesting to people that they should edit their /etc/hosts file to add in their deployment IP, I think you really should put some big bright warning that this is just for demonstration, and that OF COURSE you should use DNS to do DNS’s job. Otherwise, people will forget they fiddled with their /etc/hosts and something will break in the future. (It just will.) | 2010-11-14 | ||
238 | SUGGEST | “We can restart our application without restarting Apache at any time by creating a file named tmp/restart.txt:” Relative to what directory? /? /home/sarnold/? /var/www/? | 2010-07-25 | ||
239 | OK | The MySQL database creation code doesn’t specify InnoDB. The default storage engine for MySQL doesn’t understand ACID and certainly doesn’t understand transactions. It also doesn’t understand Foreign Key constraints, which means Rails is 100% in-charge of enforcing the sanity of the database. (I wouldn’t even run two Rails clients connected to the default MyISAM storage engine for MySQL. It might work just fine most of the time, but there’s no need to run the risk against the time that it blows up into a thousand disconnected pieces.) PLEASE create the database using InnoDB. (Or, consider switching to PostgreSQL, where no such details are necessary. I know you’ve already written a ton of MySQL content, but MySQL’s continued default use of non-ACID, non-transaction, non-FK storage engine baffles me. For any application where that is appropriate, SQLite3 is already much better suited.) | 2010-11-14 | ||
240 | SUGGEST | In the MySQL troubleshooting section, there is an attempt to connect to the MySQL server using root, but there are no attempts to connect to the server using the user name required for the application, nor specified from which machines. Since the database is going to be doing access controls based on usernames, selecting the correct one is important. Also, most admins firewall their database servers so they are only available from certain machines, so the source machine is as important as the destination machine. (Most admins also configure the database server to allow connections for users only from the machines where those users should be deployed. Belt and suspenders when it comes to your customers’ data.) | 2010-07-25 | ||
242 | OK | Why create a new dsa key? Chances are good the user already has an rsa key, and creating a second key is potentially very confusing. Also, what distributions have changed the default ~/.ssh/authorized_keys file to authorized_keys2? (Smells like a funny / strange / old version of an ssh server to me.) | 2010-11-13 | ||
256 | TYPO | “which will create this layouthis layout for you.” s/lay.*you/layout for you/ | 2010-06-27 | ||
264 | TYPO | “When starting WEBrick using with the rails server command” Delete either ‘using’ or ‘with’. Probably delete ‘using’, because ‘use the -e option’ immediately follows, and no one needs two ‘use’ in one sentence. :) | 2010-06-27 | ||
218 | TYPO | “The :test setting is great for unit and functional testing, which we will make use of in the section Function Testing E-Mail. .” One full-stop too much. I’m reading the ePub version, the chapter which I’m referring to is Iteration H1, the first page. | 2010-06-27 | ||
220 | OK | It seems like the filenames on the pages 220 and 222 are identical. | 2010-06-27 | Different portions of the same file | |
105 | TYPO | Use “default_scope :order => ‘title’” | 2010-06-19 | ||
121 | SUGGEST | Use assigns(:line_item) instead of LineItem.last to stay more consistent test “should create line_item” do | 2010-06-21 | ||
108 | SUGGEST | Expand the width of the sidebar #main { #side { Otherwise when adding the ajax effect later, an ugly overlap into the main area appears when new items are added and flashed | 2010-11-12 | ||
149 | OK | Looks bad to have the highlight effect go off when doing the blind-down effect. Here is a fix: page[:cart].visual_effect :blind_down if | 2010-07-24 | ||
173 | SUGGEST | Advise reader to restart rails server in order to refresh the routing information so that curl can retrieve the atom feed using the new route :) | 2010-07-24 | This should *not* be necessary (it was in Rails 2.x, but not in Rails 3.0). | |
183 | OK | Missing order_shipped view templates in order to run notifier test. Also missing how to run mail test: where mail method is configured to :test
# order_shipped.html.erb
Dear <%= |
In order to make DRY notifier templates, partials should be used!
What if I want to use a specific (other) line_items partial in the notifier emails than the one used on the html page.
<%= render @order.line_items -%>
In other words, describe how to explicitly tell rails which partial to use.
Also, when I in the folder views/line_items have the two partials _line_item.text.erb and line_item.html.erb I still get this error!? Should I use the “plain” part in some way?
This part of the book is really confusing…
ActionView::Template::Error: Missing partial line_items/line_item with {:handlers=>[:erb, :rjs, :builder, :rhtml, :rxml], :formats=>[:text], :locale=>[:en]} in view paths “/Users/kristian/depot/app/views”
—
Hmm, do I need to add a format.text statement or perhaps a responds_to :text at the top of the controller?
mention alternative to add a default_scope to user model similar to product instead of having the order(‘name’) in the controller. Mention use of scopes in general.
Changing the routes to use login instead of sessions/new is very nice, but it requires an update to the sessions/new.html.erb view to align it.
Also, this error is not caught by the functional test.
The HTML source code for sessins/new.html.erb (login form)
— form method=“post” action=“/sessions/new”
I was wondering why you use the will-paginate plugin but not a similar plugin, such as devise or authlogic for security?
There is no mention that you have to run
$ rake db:migrate RAILS_ENV=production
In order to setup the database in production mode for the site to run when deployed.
Showing /Users/kristian/depot/app/views/stor/index.html.erb where line #5 raised:
syntax error on line 1, col 19: ` number: currency:’
No matter what I do, I always get errors on the yaml locale file. Please post a yaml file that works as is. How do I handle whitespaces in yaml to make sure it works!?
Last sentence of first paragraph:
Reads: “…we will create tests not only the for the mail support that we just added…”
Should be: “…we will create tests not only for the mail support that we just added…”
Third paragraph, second sentence:
Reads: “(We also created a test files…”
Should read: “(We also created a test file…”
Before the new column ‘quantity’ could be successfully used in an expression, I needed to use dbconsole to actually initialize the value to something other than SQL null. RoR was throwing a nil object error when ‘current_item.quantity’ was referenced on line 15 of cart.rb. I’m using sqlite3.
Could be cockpit error but this fixed the problem.
it says:
work > rails depot
it should be:
work > rails new depot
grammatical errors …
‘and the links will only show up if there are more than than one page full’
‘We created a form to capture details for the order and linked it a new order model.’
change to .. ‘linked it to a new order model’
‘Can you find a way of disabling the button in this circumstance?’
to
‘Can you find a way to disable the button in this circumstance?’
The line_item yml as shown is invalid. It references order: instead of cart:. Also, it should be more clear that the order yml should be modified to correct the payment type for the orders since you introduced validation on the order type.
You only show the line_item fixture in the code listing.
‘And we modify the first order to’
.. should be ‘too’
The line_item fixtures as defined make sense at this point, but to reiterate my previous note on line_item fixtures, they did not make sense on page 163 because orders had not been associated to line_items at that point. That section was confusing.
‘To make this work, we need to define an route’
change to ’… define a route".
First paragraph, Second sentence.
Reads: “We can chose any name we like…”
Should read: “We can choose any name we like…”
After adding validations rules, you say that the fixtures must be updated, but the example code shows you updating the fixtures from line_items.yml, when really you should be updating the fixtures in orders_yml.
The only thing that needs to be updated for the functional tests to pass is the pay_type parameter, as we added the validation for inclusion of PAYMENT_TYPES only. Once that change is made, the tests will no longer fail.
I noticed this because you describe updating the same fixtures with the same changes twice, on page 163 and page 167.
Hope this helps!
in create.js.rjs:
page.select(“div#notice”).each do { |div| div.hide }
should be using ‘p’ instead of ‘div’
“The remainder of this method takes care of xml requests, which we will cover in on page 273, …”
Correct the “…cover in on…” in this sentence. It should probably be something like “…cover on…”, or “…cover in more detail on…”:
Underneath the excerpt from the development.log file, there is the line:
“See Figure 10.5, on page 136 for a much more user friendly result.”
I think this reference should be to Figure 10.4 on page 132.
This may be a minor typo. Page 78 reads as such: The one we’re interested in first is the
migration20100301000001_create_products.rb.
This should read: The one we’re interested in first is the
db/migrate/20100404030855_create_products.rb
Or read as such: The one we’re interested in first is the
migration20100404030855_create_products.rb
The file numbers don’t match on page 77 and 78. This correction matches them.
Page referred to incorrect: These forms are simply HTML templates, just like the ones you created in
Chapter 2, Instant Gratification, on page 34.
It was page 37 I believe.
Minor typo: Reads: At this point, you’ve done a lot a total of four commands. Should read: At this point, you’ve done a lot for a total of four commands.
please specify where .gitignore is stored. From the text below and what was written above, it is not clear where to store the file .gitignore. Is is it in the home directory?(I would assume as that is where we put the one above(.gitconfig)
Note that Rails applications are already set up to tell Git to ignore a few
files. This is accomplished by providing a file named .gitignore:
Download depot_b/.gitignore
.bundle
db/*.sqlite3
log/*.log
tmp//*
No explanation of what green pointers indicate. In the How to read this book section the below code exists with green pointers pointing to some lines of code. No where I can find does it explain what these green pointers indicate(I have read to page 88 so far).
class SayController < ApplicationController
def hello
end
def goodbye
end
end
“And because an Cart” perhaps should read “a Cart”.
I had to “sudo port install rb-rubygems” (and then reinstall the required gems) in order to get the “for cmd …” and “require ‘rubygems’ … ” scripts to work as described here. Rubygems and Rake were both still in their default locations, and “require ‘rubygems’ ” failed.
“ruby treats everything that is not false or nil as false”
shouldn’t that be “false or nil as true”?
One of the ways Rails differs differs from - > One of the ways Rails differs from
E-mail will not be delivered but instead
…
E-mail will not be delivered, but instead
If you do so, though, you’ll need also to specify some additional
…
If you do so, you will need to specify some additional
Any particular reason you double quote all of the smtp setting values except for the authentication value?
We can customize the template in order_received.erb
…
We can customize the template in order_received.text.erb
basics in place that you can place an order and have a plain email to yourself
…
basics in place that you can place an order and have a plain email sent to yourself
Inconsistent on usage of email vs e-mail
Now lets spice the email up
…
Now let’s spice the e-mail up
Unfortunately, you also need to find a way of getting appropriate e- mails from your server environment and injecting them into the application;
…
Unfortunately, you need to find a way to retrieve appropriate e-mails from your server environment and inject them into the application;
The test method get the mail class to create
…
The test method gets the mail class to create
..or..
The test method instructs the mail class to create
we have verified that the message that we intend to create
…
we have verified that the message we intended to create
Before cover-ing integration tests, a brief recap of what we have covered so far.
…
Before explaining integration tests, let’s have a brief recap of testing strategies we have covered so far.
Model classes contains business logic. When we add a product to
…
Model classes contains business logic. For example, when we add a product to
You have a heading titled ‘Unit testing of models’, but do not mention unit testing in the context of business logic. Actually, you do not mention testing at all in that section.
I think that it’s really worth giving a brief look to RVM, and perhaps the use of .rvmrc to switch gemsets when you enter your project directory.
In the section on “lock” the text “If don’t specify…” should be something like “If we don’t specify…”.
The description of public, protected, private is what you would expect for any object oriented language. Perhaps it should have a warning that anyone with a web browser can call public controller methods, and refer to the use of private in section 9.1 page 119.
The code snippet at the bottom of the page where the has_many association is added to the Order model might suggest that the entire order.rb file contains only these three lines of code, ignoring the additions to this file made earlier. I suggest adding a yellow arrow to the left of the has_many line, and either replacing the “end” on the next line with “#…”, or including the entire code for the model at this point.
You define this possibility:
Playtime
Here’s some stuff to try on your own:
• Create a migration that copies the product price into the line item, and
modify the controller to capture the price at the time of the order.
And on page 168:
sqlite> select * from line_items;
id = 1
product_id = 3
order_id = 1
quantity = 1
total_price = 28.5# <<<<<<<<<<<<<<<<<<<<<<<<<
created_at = 2010-06-09 13:40:40
updated_at = 2010-06-09 13:40:40
You assume that the reader went through will that “Playtime” suggestion, this might throw off people that did not, people that simply went through with the required steps as described in the main body of the book… this may make some feel like they’ve missed a step.
(Bottom of page, in command type)
rails new depot
should be
rails depot
Bottom of page: I think you want “./script/generate” not “rails generate”
Don’t you need to explain how to render a partial here? (_form.html.erb)
In the section for the application layout, isn’t the file “product.html.erb”, not “application.html.erb”?
Not sure that “csrf_meta_tag” is defined anywhere in the app yet.
Instead of “rails demo,” should be instructed to write “rails new demo”
In the products_controller_test.rb, I could only get it to work with “def setup”, not with “setup do” — the former can see the helper “products”, the latter doesn’t seem able to.
Code block in middle of page, I think you want “:notice” not “notice”
I had to restart the server after configuring pagination. Before doing so I was getting the will_paginate generates undefined method paginate error.
Text says:
We loaded some test data into the database, we rewrote the index.html.erb file that displays the listing of products, we added a depot.css stylesheet, and we linked that stylesheet into our page by editing the layout file products.html.erb.
It should say:
…we linked that stylesheet into our page by editin the layout file application.html.erb
When updating the StoreController, the method ‘current_cart’ is referenced, but this is the first time that the method is referenced. I think the method that should be referenced (and I have tried, and verified works) is the ‘find_or_create_cart’ method previously mentiond/described/used
The previously used <% =render(…)%> is no longer used after this point
order.add_line_items_from_cart(find_or_create_cart)
should be
order.add_line_items_from_cart(current_cart)
On MacOS X 10.6, to run sudo gem install sqlite3-ruby, you need to have installed XCode v.3.2.x, otherwise you get some ruby header missing error. You may want to mention this to users so they don’t get tripped up on this step.
Probably should use something besides ‘Pa’ for the expression interpolation example, because ‘Pa’ is already capitalized.
You suggest running
% sudo gem update rails —pre
if you’ve never installed rails and are running on a clean 1.9.2 install this won’t work. You need to sudo gem install rails —pre
You suggest running
% sudo gem update rake
With ruby 1.9.2 rake comes bundled and is not a gem. There will be nothing to update. If you make the mistake of `sudo gem install rake` (in case you went with the flow of installing rails above) then you’ll overwrite your ${RUBY_BUILD_PREFIX}/bin/rake wrapper script with a broken gem installation.
paragraph begins “If don’t specificy…” assuming it should ready “If we/you/etc don’t specify…”
This one might just be me, but when the class ‘ProductTest’ is mentioned at the bottom of the page here, it took me a few minutes to understand that we were talking about the same file we had been writing the tests in. I know I’m dumb, but it spoilt the flow for me as until this point I had known exactly where I was and what was going on (which shows how well the book was guiding me!). Maybe specify the file name/path ‘test/unit/product_test.rb’ again in brackets? - BTW. thanks for this book! Finally beginning to understand rails!
The code for the fixtures in line_items.yml reads:
one:
product: ruby
cart: one
two:
product: ruby
cart: one
When I did this, it caused the should_destroy_product test to fail. I still can’t figure out why it failed, but changing the code to the following fixed and all tests passed:
one:
product_id: Products(:ruby).id
cart_id: Carts(:one).id
two:
product_id: Products(:one).id
cart_id: Carts(:one).id
Seems the fixture needs the ids defined as opposed to the objects for some reason. Also, seemed more correct to use a different product for the second line item since we changed model to use one line item per product in each cart.
Same problem here with test fixture as on Page 164. The should_destroy_product test fails until I change the line_items fixture to specify product/order/cart ids instead of the objects.
On the following line:
list = Talks.select(“title, speaker, recorded_on” )
Wouldn’t the name of the class typically be “Talk” not “Talks”, i.e. the singular of the table name.
Doesn’t the following fail:
‘Order.minimum(:amount).where(“amount > 20” )’
as minimum returns a Fixnum thus “where” isn’t a method on Fixnum. Something like the following works:
Product.where(“price > 20”).minimum(:price)
at least in my testbed (i.e. ruby 1.9.2-rc1 and rails 3.0.0beta4)
minor bug, there’s an extra ‘.’ before “group” on the following lines:
summary = LineItem.select(select => “sku, sum(amount) as amount” ).
.group(“sku” )
there is a minor bug on these lines:
result = Order.maximum(:amount).
.group(:state).
.limit(3).
.order(“max(amount) desc” )
i.e. the extra ‘.’ at the end (or beginning) of each one. Also, I believe the maximum() call has to go at the end as it returns an actual number and thus can’t be chained this way.
I believe this line:
result = Order.maximum(:amount).group(:state)
needs to be reordered with the maximum at the end like so:
result = Order.group(:state).maximum(:amount)
I didn’t have the data to test this exactly, but with some orders in depot the following works:
Order.group(:email).maximum(:created_at)
whereas putting the maximum first errors with ‘maximum’ not being a method on UTC:Time
orders = Orders.last_n_days(7)
‘Orders’ should be the class ‘Order’
“we will be making heavy use of Rail’s ability” => saxon genitive for “Rails” should be “Rails’s ability” or “Rails’ ability”, I guess
The very first line says: “[…]. This book uses only tso Unix commands.”
Here is a typo. You probably thought about two Unix commands :)
In figures 3.1 and 3.2, there is a gray dashed arrow which goes from Model to View, different from the other arrows in the figures. I think it’s not clear the meaning of that arrow: can Model communicate directly with the View in some special way? Why is there not an arrow that goes from the View to the Model?
Sorry for my english, I hope I was clear!
Very confusing. The section where we define the relationship between LineItem and Order seems as though it should have occured at the start of the chapter (12)(page 156). Especially since the previous paragraph mentions “the has_many and
belongs_to declarations we added to the Order and LineItem models” when we haven’t added them yet. Also, the start of chapter outline lists the topics “linking tables with foreign keys” and “using belongs_to, has_many, and :through,” as the first two subjects to be covered.
book states “We need to specify that we want a version
that is greater than or equal to 3.0.pre as previous versions don’t work with
Rails 3.0.”
When running ‘bundle install’ I get the error:
“Could not find gem ‘will-paginate (>= 3.0.pre, runtime)’ in any of the gem sources.”
Ignore previous Erratum (#44094) - dumb typo on my part.
Though, I did need to upgrade Sqlite3 on OS X (leopard) and run ‘sudo bundle install’.
Current text is:
—
Armed with all this background about flash data, we can now change our create method to intercept bad product ids and report on the problem:
—
The problem is that the code below and the changes made are to the show method not the create method.
Current text is:
—
/* Styles for the cart in the main page */
#store .cart_title { font: 120% bold;
}
#store .item_price, #store .total_line { text-align: right;
}
#store .total_line .total_cell { font-weight: bold; border-top: 1px solid #595;
}
—
I’m no CSS guru but it seems redundant to include #store twice on the row with .item_price and .total_line, and the block after this one seems to do this without repeating itself.
Since the end of Chapter 6, there shouldn’t have been any modification done to app/views/layouts/products.html.erb, so the output from
$ git status
should not include this line:
In the Playtime section, adding:
validates_length_of :title, :minimum => 10
to the product model did not result in any unit test errors even though it says:
Note: this will cause tests to fail, so you will need to
update the fixture data for products.
The fixture data for the product title is: “Programming Ruby 1.9”
The width for the sidebar is too narrow. When adding the item Programming Ruby 1.9 it overflows into main. Changing the width for the sidebar to 14em and changing margin-left in main to 15em fixes this but it really isn’t a very good solution. The problem in this case is the word “Programming”, which is too large to fit, this fix just bypasses the width problem for this specific case and if you create an item with a longer word like “Antidisestablishmentarianism”(longest word found on wikipedia) you have the same problem again. There must be a better way around this, maybe the cart should be moved to the bottom instead in an floating div?
The listing for helper files is incomplete it contains helper files for application, carts, line_items, products and store. I don’t know if this was intentional?
Maybe reminder to delete layout/order.html.erb so that the .css gets picked up?
Is @order.add_line_items_from_cart(current_cart) explained someplace?
D’oh!! Ignore my knucklehead “add_line_items_from_cart” comment.
Inside the “Joe Asks” box, 3rd para, “has chose” should be either “chose” or “has chosen.”
add some explanation of the changes to the functional test here.
hadn’t you already handled the ‘wibble’ case:
def current_cart Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound cart = Cart.create session[:cart_id] = cart.id cart
end
it looks like a wibble would be not found, and thus just create a new cart. if not, you could explain why not here.
Title for section 19.4 should probably have a comma between Reading and Updating.
Title for section 21 should probably have at least the first letter R capitalized.
In general, chapters with only one section (20, 21, 23) should probably not have a subsection, unless you plan more and the .1 section is just the first written.
“The changes to Rails … [were] the requirement… and the fact….”
Remove “to”: “… describing what goes into [to] each.”
Too few text lines to justify a page.
Do the little teasers that start each chapter really have to be bulleted? A single sentence lead-in is a very useful tradition, once in the table of contents to make that an even better guide. Here, though, adding actual bullets for a few words just makes it look like an ill-conceived mini-slide from the book proposal.
Consider a colon instead of an em dash in “don’t repeat yourself[—][:]every piece of knowledge”, since the second clause defines the term used in the first. The em dashes later in the paragraph are better used.
“to already-displayed pages in on page 308.” “in on” should be “on”
After modifying the test cases as indicated (all previous steps followed) the test cases still do not pass. See below:
kuccello:~/Development/SoldierOfCode/Experiments/depot(iteration-b1) >> rake test
(in /Users/kuccello/Development/SoldierOfCode/Experiments/depot)
Loaded suite /Users/kuccello/.rvm/gems/ruby-1.8.7-p299@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
.
Finished in 0.110124 seconds.
1 tests, 1 assertions, 0 failures, 0 errors
Loaded suite /Users/kuccello/.rvm/gems/ruby-1.8.7-p299@global/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
F…..F
Finished in 0.31331 seconds.
1) Failure:
test_should_create_product(ProductsControllerTest) [/test/functional/products_controller_test.rb:26]:
“Product.count” didn’t change by 1.
<3> expected but was
<2>.
2) Failure:
test_should_update_product(ProductsControllerTest) [/test/functional/products_controller_test.rb:45]:
Expected response to be a <:redirect>, but was <200>
7 tests, 9 assertions, 2 failures, 0 errors
Errors running test:functionals!
In the bullet list at the top of the page, “updated” should be “updating”
“type rails followed by the name of our project.” should be “type rails new followed by the name of our project.”
There are some extra words in “which loads stylesheets from in the public/stylesheets.”
The first bullet point at the top of the page ends with a period. This is inconsistent with the format of the bullet points at the beginning of all the other chapters.
“each of the named fields are present” should be “each of the named fields is present”
“and their contents are not empty.” should be “and its contents are not empty.”
At the beginning of 10.3 chapter:
“<%= button_to ‘Empty cart’, @cart, :method => :delete,
:confirm => ‘Are you sure?’ %>”
:confirm => ‘Are you sure?’ doesn’t work (it doesn’t generate any javascript confirm)
<input type='submit' value='Empty cart' data-confirm='Are you sure?'/>
\n
\nThis data-confirm attribute is processed by /javascripts/rails.js
to produce the popup.
The expanded view in figure 2.3 incorrectly has html for an entire page, when in reality it should only have
Hello from Rails!
given that the rest is generated in the application layout at this point.
depot_l app to demonstrate Ajax support does not work. I have gone through Troubleshooting points on page 145 and none of them applied. On adding a product, this is what I see in the log:
Started POST “/line_items?product_id=1” for 127.0.0.1 at 2010-07-26 14:16:09 –0700
Processing by LineItemsController#create as HTML
Parameters: {“authenticity_token”=>“DS4HwtXTxypkVH2J+14r17D6DQkFatQtuAgq73l03dE=”, “product_id”=>“1”}
Had it worked, I believe it would have said #create as JS or RJS instead of #create as HTML
Would appreciate if you respond to aminm@fastmail.fm
“Fully-fledged” is a compound adjective, so should be hyphenated.
This means that will need to display a Rails template containing a form.
Should probably read:
This means that we will need to display a Rails template containing a form.
The word “requires” is duplicated first bullet point, second line says “Rails 3.0 requires requires Ruby version 1.8.7…”
“(by default in the directory as the object being rendered” should be “(by default in the same directory as the object being rendered”
“This section contains the links and instructions to get that done.” All the following instructions download files and refer to home pages, but don’t specifically mention what files need to change, or compile commands to run per database driver. Changing wording to “links to instructions” seems more correct.
The first sentence of the page has an extraneous “in”. It reads: In the example above, two products in contain the same title.
why the :on => :member ? the resource routing here is not well explained
on this page you talk about eating our own dogfood by using .salt rather than the salt instance variable. but why do we use
var in many other places in the program? it feels like there’s a good little sidebar here that got started but never finished. it’s half explained - just enough to make new ruby devs to say um… wait, what was that again?
Last paragraph, “If you look at … you’ll see tracing …” I don’t see tracing until I go to one of the application pages, like …/say/hello.
I was keep running tutorial since beginning. When I try to add will_paginate,
bundle install work without problem, but the the OrderController code can’t find Order.paginate method.
This was because I haven’t restarted the server. I think it is better to mention to restart server after bundle install.
“And because an Cart is declared to have many line items, we can reference them (as a collection) from a cart object:”
Should be “a Cart” not “an Cart”
How about footnoting “the PickAxe book” for us beginners?
orders = Orderlast_n_days(7)
should be
orders = Order.last_n_days(7)
I think there’s a part missing in the last sentence of the introduction:
“Finally, we will cover a few thingssessions, flash, and filters.”
“Figure 11.3: An error in an layout can affect the entire application” should be “a layout”
<%= form_tag do %> seems to give error, while <%= form_tag :login do %> works
thanks
I’m a beginner and do a lot a flipping around to understand what is going on. On page 55 there is a reference to xml builder template starting on page 342. When I click on “342” it brings me to between Chapter 21 “Action View” which hasn’t been written yet and Chapter 22, “Active Resource” with a note that the content will be lifted from Chapter 26 in Ed 3. Is there any way I could have access to Ed 3 or some info that currently isn’t included in my B6.0? Thanks so much! I’m enjoying the process of learning Ruby and RoR thanks to you.
There’s a period missing after this sentence: Note that each route is defined with an optional format specifier
In the first sentence “The links to the actions that edit an product …” it should say “a product”.
There’s a second occurrence of “an product” in the first paragraph.
“creating an simple application” should be “creating a simple application”
Not sure if this will be fixed with the official release of Rails 3, but ‘rake doc:rails’ fails with “File not Found: lib” - from what I’ve read on this error in forums, I gather that the documentation for Rails 3 either isn’t done or doesn’t install properly? If it’s not fixed by the publishing of the book, it might be wise to mention that.
During this setup process, I installed e-TextEditor, which prompted to install Cygwin, so I did, which royally bit the wax tadpole. Git no longer worked, and I had to do a system restore to get it functioning again. Might put at least a warning about Cygwin, or at most some instructions about getting e-TextEditor to play nice with Git. I just abandoned it altogether.
“You will find out on on page 262” should be:
“You will find out on page 262”
“Let’s start by creating an simple application” should be
Let’s start by creating a simple application
In the last paragraph the text reads
“… starts find_or_initialize_by_ or current_cart will call either new of create …” I think current_cart should actually be find_or_create_by_
David
The YAML for currency localization on pages 226/7 does not work.
I had to remove the currency: line and then correct the indentation.
Middle of the page says "Rails has the ability to import seed data.
To start, we simply create a file in the db directory named seeds.rb"
That file, seeds.rb, is created with the “rails generate scaffold…” command. To add seed data we must modify or add data to that already existing file.
“…that Rails makes available to you as the path to the /say/goodbye path” doesn’t make too much sense to me. It should probably say something like “…that Rails makes available to you containing the path to the goodbye method of the say controller (in this case ‘/say/goodbye’)”
When I Ctrl+C WEBrick in Windows I get “Terminate batch job (Y/N)?” It might be good to mention this, just so it doesn’t come as a surprise. As far as I can tell, it doesn’t matter which you choose.
This may be a nitpick, but my brain got stuck trying to figure out the purpose of the code at the top of this page (even though it was just there to indicate the syntax of the “if” structure). Does it actually make sense? I don’t think it does…
First paragraph: “When creating a table, fields defined include…” should probably say “The fields defined when creating this table include…”
My first reaction was that these fields are what should be declared for every table you create… until I realized that didn’t make sense :)
It would be GREAT to mention in the sections on “a || b” and “a ||= b” that these shortcuts also support setting values that are not currently defined (“a ||= b” doesn’t throw an error, like you would get using “if !a then a=b end”, which is probably a common mistake in trying to set a default value), and is therefore the preferred syntax for setting a default value (aside from method parameters).
(P.S. Not sure if this is the right page - none of the previous errata displayed here seem to pertain to the page I’m looking at…)
Last paragraph: “We’ll do this using the format_of option” should just be “the format option” - unless I’m missing something (the code sample just uses “format”, not “format_of”).
The listing of products_controller_test.rb is missing a couple tests after “should create product” - probably should add the rest of the automagical tests (mine has “should show product” and “should get edit”), or at least indicate them with “[…]” or something.
2nd paragraph outside “David Says” box: “table will be… populated with the new single row for the Ruby book” that’s true - but it will also be populated with entries “one” and “two”, since we left those alone, right?
Troubleshooting - I had an error in my create.js.rjs file which WEBrick reported very nicely in the rails server window, so that may be another place to look.
In the first paragraph of section 1.2, first sentence, the wording doesn’t read well. I think you wanted to say something like, “While versions of OS X since 10.4.6 (Tiger) have included …”.
Paragraph: “It’s time to check it all in and move on to the next task, namely, making the
Add to Cart link actually do something!”
TYPO: We have not created any ‘Add to Cart’ link yet. That task takes place on the next chapter.
SUGGESTED CORRECTION: “It’s time to check it all in and move on to the next task, namely, where we’re going to create an fully functional Add to Cart link!”
Hope this helps. I was kind of confused the first time I red it.
It reads “The relationship between Orders and Parts through LineItems is an example of such a relationship.” where I think it should be Carts instead of Parts.
In the last sentence of the last paragraph before 19.4, there is a “to” where a “do” should be.
The second sentence of that page: “You saw how to create*d*, read, update, and delete this data.”
there is a third occurrence of “an product” in the paragraph after the first code snippet.
in the thirt paragraph from the bottom it reads “an product”.
You should explain in deep what the .build method do.
For a newbie like me it was VERY confusing and I had to search on the Internet to finally find out that it was a default behavior of Rails. You didn’t explain it.
What to do when things go wrong.
It would be handy to have a list of things to check when troubleshooting.
Logs, setting debugging levels, strategies to find where the elusive bug is. I’ve spent days looking at what is probably the same bug with a transaction thats backing out and I don’t know why. The error seems to be “undefined method `delete’ for nil:NilClass (NoMethodError)” and there are warnings of shadows variables and previous engine definitions.
It would be nice to have practical advice on how to identify if the problem is with my environment, my code or what I’m trying to make rails do. How can I make the errors more detailed, can I use a debugger, should I insert print statements or increase verbosity?
The second bullet isn’t being performed and should be removed since the explanation of :notice is done in the 3rd paragraph
“Ruby on Rails is an MVC framework”. I think it must be only an “a”.
I recommend reworking the first part of this sentence or breaking it in two. It’s in the bullet at the top of the page: “In addition to the wide range of parameters the link_to method we encountered in the templates takes, this method accepts a :notice parameter which will store the specified message in the flash as a notice.”
It just doesn’t read easy and it should ensure any correlation to the link_to method is actually useful - otherwise it’s confusing. I had to read it a few times to make sure I wasn’t missing something.
BTW, in #44460, I meant “3rd bullet” not “3rd paragraph” :)
The first sentence states, “we have to add a link to the cart and implement an empty_cart method in the store controller.” But we don’t actually get to that in the iteration.
The second paragraph might read easier if you combined the 2 sentences: “… destroy method so it removes …”
In the explanation of the code changes to orders_controller.rb (1st paragraph) it says “we redisplay the catalog using our redirect_to_index method” when in fact we don’t.
Figure 12.3 shows the error_explanation div outside of the depot_form div. In my experience, the instructions place it on the inside. I think it looks better on the outside, but I’m not sure it’s worth the extra steps.
The last paragraph needs more explanation. What is Builder? I see section 21.5 isn’t written yet, but would recommend a link to the section once it’s written. It’s also not clear the relationship between the format.atom call in the action and the atom_feed builder (helper?).
The last paragraph of 12.1 states we’re going to create a “feed of orders” and it’s not clear why we’re jumping into ProductsController. Wouldn’t /orders/history make a better feed address than /products/3/who_bought?
The code-added-or-changed-on-this-line indicator is missing from the first 2 lines of the index action code snippet.
This and the previous page (195) state the use of the SHA1 hashing algorithm when we will actually use SHA2 as seen on the next page (197).
After clicking “Add User”, the index is redisplayed, but without the cheery flash notice. It seems to be missing from the view/layout.
Figure 14.2 must be recreated since there is no login action in the sessions controller.
In the 3rd paragraph, “,as we did for the login method” should be removed since there is no login method (and we haven’t whitelisted any yet).
In the first paragraph, you might consider a short note reminding the reader they are likely already logged in to the site. So they should restart the browser or the web server to see the redirection since we haven’t implemented logout yet.
First sentence of Iteration I4: “Let’s start with adding a links to …”
“profiler” is listed twice. I think the first one doesn’t fit into the alphabetically sorted list.
In the first code snippet, the :only parameter should include :destroy, not :delete. Otherwise, users will be prompted to login to empty their cart.
“Now we ready…” should say “Now we’re ready…”. It’s in the middle of the page.
“we will cover in more detail in on page 132.” remove the “in” after the word “detail.”
Screenshot error. After you have added the first line item to the cart the cart will have the new style that we did in the previous chapter. The screenshot shows a vanilla page that has none of the styling.
“That means our partial will be stored in the file _line_item.html.erb in the app/views/line_items directory.” – The partial file is not created automatically.
The whole test code for “should create line item via ajax” is new to the file, but there are only triangles on some of the lines.
The first sentence of the third complete paragraph seems to contradict the third sentence in the fourth paragraph of the “Preface to the Fourth Edition” (page 13): “But the biggest change is in the final section: as it is no longer practical to cover the entire ecosystem of Rails….”
In the second-to-last sentence on the page, you have, “… and the product_id identified a product.”. This doesn’t read well to me. It seems that it would be better if it was, “… and the product_id of a product.”
Missing triangles.
Missing triangles.
“we use these commmon Ruby idioms…”
commmon -> common
The order_shipped test will fail with an error at this point, if you’ve only been following along with the code in the book and not downloading mailers/notifier.rb. The method order_shipped hasn’t yet been defined to take an argument, which is passed from the test.
In the new HTML for index.html.erb, it would probably look better if the link to new product on the bottom of the page had the word “product” capitalized.
In the last paragraph, you talk about how we edited application.html.erb to include a link to depot.css. The generated application.html.erb file already contained the line “<%= stylesheet_link_tag :all %>” so we didn’t need to edit it.
curl is not installed by default on Windows, afaik. Would it make sense to add curl to the Installing on Windows section?
The paragraph starting with “A block must appear after the call to a method” isn’t clear to me. I’m not entirely sure what this is trying to tell me, since I see other examples where a block clearly isn’t preceded by a call to a method. Can you provide some clarification here?
In the first sentence after the product.rb code listing, you use present tense for “declare” but past tense for “defined”. It would probably read better if both were present tense or both were past tense.
In the third paragraph of section 9.3, last sentence, you refer to the source file for the line items controller without the “.rb” extent. It should be, “… method in app/controllers/line_items_controller.rb, …”
In the second to last paragraph, third sentence, you refer to the line items controller file without the “.rb” extent. It should be, “See the comments inside the app/controller/line_items_controller.rb file …”
In the code for test “requires item in cart”, all the lines for this test should have a triangle to the left since it is a new test.
In order fixture one, there should be triangles next to the name and email fields in addition to the one for pay_type.
In the sentence before the order.rb code that adds the has_many relationship, it says that the :dependent attribute means the line items will be destroyed when the “cart” is destroyed. Should that be “order” instead of “cart”.
The line_items.yml file at the top of the page is identical to the one on page 167 and it seems redundant to talk about the fixture and list the fixture source here.
Last sentence in the second paragraph of 4.5 needs some attention.
The who_bought method is being introduced for the first time. There should be triangles before all lines.
In order for the “bundle install” command to work, the user may need root privileges. You should probably add a footnote about that.
After making the changes for will_paginate, I had to stop and restart the rails app for the changes to take effect. Maybe you should mention this before telling the user to try it. Before I did that, I got the following error:
NoMethodError (undefined method `paginate’ for #
app/controllers/orders_controller.rb:5:in `index’
After stopping and restarting the server, everything worked.
In the paragraph after the code listing for index.html.erb, second sentence, you have repeated the word “than”.
In the paragraph after the code listing for index.html.erb, third sentence, you have used the word “specify” instead of “specifies”. It should read, “The controller specifies the number of …”
In order for the functional tests to pass, you need to add a line to the line_items.yml fixture file to have a line item for order one that has the Ruby 1.9 product.
Has already been mentioned, but when I do rake doc:rails, I get:
rake aborted!
Don’t know how to build task ‘README.rdoc’
Second line, “fields” should be “field”.
The test assertion for the From: header does not match the code on page 184 where the default from is set to from@example.com. You should update the original code or update the test so they match.
The “Add User” button actually shows up as a “Create User” button.
It would probably be a good idea if the login form displayed the alert message if the previous login failed.
In the sentence after the application_controller.rb listing, there are two periods on the end of the sentence.
After making all the changes described in section I3, the integration test still fails.
Please ignore erratum #44607. I had a typo in the skip_before_filter statement in the orders controller. Sorry for the false alarm.
The translation key for the “Add to Cart” button needs to be named add_html since there is a HTML entity in the spanish version.
For the cart translations, you should also translate the confirm text. Since the spanish will have a leading upside down question mark as well as an a acute, it will need a trailing _html in its name.
In the english translation for the legend, the word “your” should be capitalized as it was in the pre-translation template file.
In the spanish translation, the address and pay_prompt strings both contain html entities. These keys should end in _html.
In config/locales/es.yml you have left out the lines that translate activerecord.models.order. It should be:
activerecord:
models:
order: \t "pedido"
errors:
messages:
inclusion: "no está incluido en la lista"
blank: "no puede quedar en blanco"
errors:
template:
body: "Hay problemas con los siguientes campos:"
header:
one: "1 error ha impedido que este %{model} se guarde"
\tother: "%{count} errores han impedido que este %{model} se guarde"
In the code for _form.html.erb, in order for the output to look like figure 15.8, you need to add the following line right before the
tag:
<%= t(‘errors.template.body’) %>
You point out that store_controller’s index action needs cart = current_cart, but because you've added render
cart to the application layout, many of the other controllers’ actions need to set @cart = current_cart as well. Otherwise 9 of the functional tests fail and the app quickly shows these failures, too.
In the code:
—-
test “requires item in cart” do
get :new
assert_redirected_to store_path
assert_equal flash[:notice], ‘Your cart is empty’
end
—-
Only the two lines beginning with assert have a green arrow before them, all the lines should have green arrows.
I get a “method does not exist” error when trying to use the “validates” method as described in the book. But “validate” seems to be an actual method: is that what you meant? (I am still running rails-2.3.5, however.)
About MySQL you write: “It already is included in OSX”.
That is not true, except if you run Mac OS X Server. I had to download it manually and then install the gem using ‘sudo env ARCHFLAGS=“-arch x86_64” gem install —no-rdoc —no-ri mysql — —with-mysql-config=
/usr/local/mysql/bin/mysql_config’
“By the time we were done, we created nine controllers: one each for the six models, and the three additional ones for to support the views for admin, sessions, and the store itself.”
There are only five models and thus only five controllers for these. The 9th (or 1st) controller is the ApplicationController.
Been doing the Iteration F4. When tried to change the application.html.erb to the one shown on the page 152 (the line “<%= render(:partial => ”cart“, :object => cart) %>", got error: ActionView::MissingTemplate in Store#index. Restoring to "<%= render
cart %>” helped.
"If you look in the app directory, you’ll find four subdirectories:
depot> ls -p app
controllers/ helpers/ mailers/ models/ views/
"
There are five subdirectories in the book. In my app/ there are four subdirectories (without mailers) though.
Last sentence: “It also allows us to focus on a smaller set of variables at any one time, which will make untangle any problems that we might occur easier to address.”
Suggestion: “It also allows us to focus on a smaller set of variables at any one time, which will simplify the process of untangling any problems that we might encounter.”
I am running Mac OSX Leopard 10.5.8 on a NON-Intel processor. Xcode 2+ developer tools require an Intel-based mac running Snow Leopard (OSX 10.6+). Xcode 3.1.4 Developer Tools currently seems to be the highest release number for non-Intel based Mac’s that cannot use Snow Leopard. Also, XCode should probably be installed/updated BEFORE trying to use MacPorts to install Ruby 1.8.7. This is not clear from the ordering in the text.
In the index, Fragment Caching says “See Caching, fragment” - but there is no such entry in the index.
<%= render @order.line_items -%>
Why there is %> at the end? If it’s not a typo (I didn’t find any info on that), it would be nice to write: Notice the%> at the end. It means that blah blah blah
“This has lead to a reorganization of the book.”
Should probably read
“This has led to a reorganization of the book.”
Your explanation of the use of runner is very short. It would be useful to point out that it is really the non-interactive equivalent of console. There is also no discussion where runner script files should be stored.
I have only recently learned about runner even thought I had read the book cover to cover. I basically missed the relevance and method of use of the runner script.
It would be useful to mention something about seeding the test database, particularly if the test is being designed around a database with many initial values. While your book never really addresses this issue, a brief hint on this page would be really important. Particularly if one want to use very realistic dataset to set the application.
rake db:seed RAILS_ENV=test
Hi
Installing using MacPorts. Need to run
“sudo port install rb-rubygems”
just after “sudo port install ruby” or else the gems get installed in the wrong place.
Cheers
First sentence on this page: “At this point, you likely to have two versions of Ruby on your system” -> “At this point, you are likely to have two versions of Ruby on your system”.
In the code listing, the translation for cart, namely t(‘.add’), should really be t(‘.add_html’), since we use “Añadir al Carrito” as a translation for “Add to Cart”, and without ‘.add_html’ as the translation qualifier, Rails won’t parse the html character entity.
The above change will get Rails to render the store template properly, as in Figure 15.4
Under the code sample: To pass a block to a method, place the block block after the parameters -> To pass a block to a method, place the block after the parameters
“outside a web server”
I think you mean “outside a web browser” — you have to have a web server to access any rails app, right?
By convention, the template for action action of controller control will be in the file app/views/control/action.type.xxx (where type is the file type, such as htmlatom or js; and xxx is one of erb, builder, or rjs). The app/views part of the
*… app/views/controlLER/action.type.xxx
*… such as html
“Generate” lists the old command for executing generate. It should be updated to 3.0.
It might be nice if you allowed for directory listings in the stylesheets directory that you suggest people download from. You do link the actual css files but… it might be nice if we could see the directory.
The first item of playtime references page 117 and says that it is talking about making an image clickable… i don’t see anything about this on that page.
I had to restart the webserver in order for the will_paginate gem to load.
I don’t know if I am wrong here, but we have a reference for deprecated error_messages_for helper in the first paragraph of this page, and also the code could not be addressed in the code in pages above.
I saw also references to error_messages_for in page 353 inside a code block of example: e1/views/app/views/upload/get.html.erb, and in the index at least 2 times.
att.
Alexandre da Silva
postgres-pr is no longer available at rubyforge.org/projects/ruby-dbi but has moved to rubyforge.org/projects/postgres-pr.
See this post: rubyforge.org/forum/forum.php?forum_id=28192
In the display for the notifier.rb you show the order_received function change but not the order_sent, the download does have it but if you’re simply copying/pasting from the book you won’t know until your test fails with the tests you’ve given on page 190
You say that after clicking ‘create user’ “the index is redisplayed with a cheery flash notice.” but the index you’ve provided has no flash notice display, so all we see is the list of users.
the wiki you point to is seemingly for a previous version of the book.
In the ePub version there’s no fixed-width font for constants, commands, etc. in regular text.
It could be the case that’s a technical limitation of ePub, but Sam suggested that I open a ticket to check it out.
says:
a = %w{ ant bee cat dog elk }
should use ( and ):
a = %w( ant bee cat dog elk )
The sentence “The say_goodbye_path is a precomputed value that Rails makes available to.” is incomplete. It looks like the words after “to” are missing.
The punctuation is missing at the end of the page — “a brief introduction—to the Ruby language itself” is how the chapter ends. I think all it needs is a period.
Saying “rescue clauses can be directly placed on the outermost level of a method definition without needing to enclose the contents in a begin/end block” is correct and good as a refresher for people who are accustomed to Ruby, but I’d give at least one small example of this so people have some idea of what this means. Most languages don’t have anything quite like this.
Paragraph 1 - “Currently our cart is rendered by the index action…” I believe “index” should be changed to “show”.
Going to second the already submitted suggestion:
The AWDWR book has always done a really good job of giving good explanations for all the building blocks upon which it constructs the story through out the “Building an Application” chapters. On pg 125 it introduces the line_items.build method but hand waves over its description. I’ll cast my vote to keep the quality of this book high and ask for a better explanation for .build
In the entire user model, the very first line " require ‘digest/sha2’ " exists, yet was not referenced in the steps/example whatsoever. Also, something should be said to the order and placement of new def & class codes in this example.
Just under the “Helper Methods” heading, it says “If you look in the app directory, you will find four subdirectories”, but then you show the output of ls p app, which contains five, including the mailers directory. :)
Incorrect grammar in the sentence below.
The should get index test gets the index and asserts that a successful response is expected.
“and finallyto substitutes that string into the resulting page” you probably mean ’finally"
You should call the OS GNU/Linux, not just “Linux” that is the kernel alone. For people like me, that strongly believe in freedom and the importance of Free Software (Free as in freedom, not price) it’s a very important point.
If you want help spread the Free Software concept, and give merit to who deservers it, the minimum you can do is respect the GNU OS and mention it with “GNU/Linux” and not Linux alone.
The high technical level and quality of “Pragmatic” collection needs you not to do such a mistake.
So please, just substitute all the occurrence of “Linux” with the more precise and ethically correct “GNU/Linux”.
Thanks
In the bullet point about config.ru on the bottom of the page, I am totally unable to parse the first sentence. It looks like something is missing or multiple sentences were stuck together without fixing them up.
End of second paragraph “save the result into a local variable named @line_item”, should be “instance variable”.
As pointed out in one of the other comments, <%= render cart %> causes problems if you're trying to use the other controllers, as they aren't setting
cart to anything.
I worked around this with <%= render cart unless
cart.nil? %>. Production code-worthy, maybe not, but it makes everything work nicely again and is a small change.
(Note: I previously submitted this for page 144 for the wrong version. Sorry!)
<%= render cart %> here causes the view to fail for any controllers other than the store controller. To get around this I used <%= render
cart unless @cart.nil? %>.
In the pagination section (12.3), after doing “bundle install” I had to restart rails before pagination would work. Rails couldn’t find the .paginate method, so it would seem that rails didn’t pick up the new gem. In other words, you may need to suggest that people restart their server.
Last sentence of Section 22.2 has a ‘t’ after ‘cover’: “We covert why that is useful and how to integrate it into your application next.”
Extraneous period in the first sentence of the second paragraph of the ‘What We Just Did’ section: You learned how to cache entire pages, and thereby avoid all Ruby, Rails, and database overhead when processing requests that can be served by the cache..
Not clear if you are trying to describe the generated migration file name as a regex or a timestamp. It might be more descriptive as a timestamp (yyyyMMddhhmmss_create_discounts.rb).
Last paragraph on the page. Since the terms ‘precision’ and ‘scale’ are being used in the context of an option they should be in the code font and prefixed by a colon, which has the added benefit of enhancing searchability.
The ‘should_create_line_item’ test is the only place in the book where the user is instructed to type in the word ‘assigns’ - while ‘assigns’ is in test code snippets elsewhere in the book, it’s not as something you need to enter or modify.
Unfortunately, ‘assigns’ isn’t documented anywhere in the book (and it’s not documented well online, either). You can sort of guess what it does, but without clear explanations it’s just another bit of magic voodoo that makes learning to use Rails so frustrating.
might be wrong, but I’m not sure that ‘ex’ is a proper spacing label
In the #main css settings
padding-left: 4ex;
should be
padding-left: 4em;
The code at the bottom of page 94 has a closing curly brace, but it is on the next page and it is after figure 7.1. Another words figure 7.1 is in the middle of code.
<%= button_to ‘Empty cart’, @cart, :method => :delete,
:confirm => ‘Are you sure?’ %>
Should the method be (:method => :destroy)
The code snippet for CartsController skip_before_filter :authorize specifies :delete as a method to skip. I assume that should be :destroy
I know it’s obvious, but for some newbies it may not be. Under “Creating a Rails Application” subheading instruct the reader to create a folder named “depot” and cd to that folder before running the rails new depot command.
The code at the end of page 104 continues on page 105. The problem is, the remaining code displayed on page 106 it’s just a closing bracket, displayed after Figure 7.1 It might be a bit confusing. The first time I went through it I didn’t notice the closing bracket, reloaded the Webpage and got a " syntax error, unexpected kEND, expecting ‘}’" error.
Please disregard #45008. Here is the corrected suggestion. The code at the end of page 104 continues on page 105. The problem is, the remaining code displayed on page 105 is just a closing bracket, displayed after Figure 7.1 It might be a bit confusing. The first time I went through it I didn’t notice the closing bracket, reloaded the Webpage and got a " syntax error, unexpected kEND, expecting ‘}’" error.
The beginning of the code for products_controller_test.rb doesn’t need the “#…” since there is nothing between
class ProductsControllerTest < ActionController::TestCase
and
setup do
In the last sentence on the page, you have used the word “sets” when I think you meant to use “set”. It should read, “The standard environment that these files set up …”.
validation code not in 3.0 form
as is: validates :price, :numericality => {:greater_than_or_equal_to => 0.01}
should be: validates_numericality_of :price, :greater_than_or_equal_to => 0.01
The table of naming conventions is a little difficult to read. I would lighten the gray background for the headings going down the left side and also lighten the blue background for the values.
join(‘; ’) is not explain what it does
scaffold generator now also creates scaffold.css
In the first sentence on the page, you say that figure 19.1 is on the next page when it is on the same page. In fact, it immediately precedes the sentence that says it is on the next page so it is highly unlikely that it could possibly be on the next page.
In the third paragraph, you have used the word “scopes” when I think you wanted to use “scope”. it should read, “Relations are equivalent to an anonymous scope:”.
The first paragraph of the section titled “Nested Resources”, second sentence, reads awkwardly. I think you have an extra word “on” toward the end of the sentence. I think it should read, “… to allow folks to review our products.”.
In the second paragraph, third sentence, you have used the word “products” when I think you meant to use the word “product”. It should read, “… by the path to a particular product.”.
In the first paragraph of the section named “Shallow Route Nesting”, first sentence, there should either be the word “a” before “cumbersome URL” or “URL” should be “URLs”.
In the last paragraph on the page, first sentence, toward the end, you have run the words “html” and “atom” together without an intervening comma or space.
In the text describing send_data, it looks like the font size for descriptive text is not the same size as in the rest of the book. It’s like the font size was adjusted down for the word “send_data” and not restored afterward. The same appears to be true for send_file on the next page.
In the text describing :url_based_filename, second sentence, it looks like you have an extra word “to” before the word “handle” toward the end. It should read, “… in order to make some browsers handle i18n filenames correctly.”.
In the first paragraph of the section “What We Just Did”, third sentence, it looks like you are missing the word “the” before the word “primary”. It should read, “In nearly every application, this is the primary place …”.
In the second paragraph of the section “What We Just Did”, first sentence, it looks like you are missing the word “the” before the word “way”. It should read, “… which was the inspiration for the way in which …”.
In the fourth paragraph of the section “What We Just Did”, second sentence, you have repeated the word “in”. It should read, “Now that you have seen each in use …”.
In the second paragraph, second sentence, you have an extra word “to” before the word “cover”. It should read, “We will then cover a number of …”.
In figure 21.2, in the descriptive text for item 3, it looks like the word “which” is missing after the acronym “HTML”. It should read, “the HTML which is sent …”.
At this point, we are in a section named, “21.5 Creating Your Own Helpers”. However, starting with the heading “Helpers for Formatting and Linking”, you are no longer talking about creating your own helpers and instead, talking briefly about some of the helpers that come with Rails. It seems to me that you should have a new major section at this point.
In the last paragraph on the page, second sentence, you used the word “providing” when I think you wanted to use the word “provide”. It should read, " Intermediaries between your server and the client may also provide caching services.".
The image used for figure 22.1 extends off the right side of the page, and thus is not showing the changing time. It should probably be scaled down so that it fits.
It looks like there is a formatting error here. Skipping to the next page to start the next subsection after only printing 2 lines on this page seems a bit extreme.
In the code for the migration 20100301000003_create_line_items.rb, the surrounding text implies that you have added foreign key constraints using the option parameter. It appears that these parameters are not in this code.
Linux install. Since we are now in Rails 3 release can you update the install advice - Ruby 1.9.2 and Rails (not —pre)
In the third paragraph, first sentence, you have an extra word “your” before “the config/environment.rb”. It should read, “For this to work, Ruby will need to find the config/environment.rb …”.
The 11’th bullet point is named “Class” and it should be named “Module”. It should read:
Module: accessors for module attributes, aliasing support, delegation, dep-
recation, internal readers and writers, synchronization, and parentage.
summary = LineItem.select(select => “sku, sum(amount) as amount” ).
group(“sku” ). The (select => does not work for us using Rails version 3.0.0.rc2. The (select is out of place. The error reported is:
irb(main):022:0> Product.select(select => “id, title”)
ArgumentError: wrong number of arguments (0 for 1..4)
from (irb):22:in `select’
from (irb):22
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc2/lib/rails/comma
nds/console.rb:44:in `start’
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc2/lib/rails/comma
nds/console.rb:8:in `start’
from C:/Ruby/lib/ruby/gems/1.9.1/gems/railties-3.0.0.rc2/lib/rails/comma
nds.rb:23:in `<top (required)>’
from script/rails:6:in `require’
from script/rails:6:in `
’
irb(main):023:0> Product.select(:select => “id, title”)
(Object doesn’t support #inspect)
=>
In the second paragraph after the heading “What We Just Did”, first sentence, you have repeated the word “to” after the word “Resource”. it should read, “Finally, we used Active Resource to break free …”.
The code change to display the error header should be wrapped in an
block. This will continue to display it with white text on a red background (as shown in the picture on the following page).
<%= t(‘errors.template.header’, :count=>@order.errors.size,
:model=>t(‘activerecord.models.order’)) %>:
“And that is all there is too it!”
should be:
“And that is all there is to it!”
About rails supporting RJS… I think this section should be re-written in the way how rails 3.0 supports unobtrusive javascript and give examples of both using prototype and jQuery. RJS is still suppoorted but considered legacy now.
Shouldn’t the bracket for the code come before the figure 7.1?
In the “Joe Asks…” Box, it says that the “techniques described in this chapter can be used by those developing on
Windows and deploying to Linux or Mac OSX.” I don’t believe that there is a Windows port of Passenger.
An extra period precedes the footnote 6 marker:
“… we created a new application stylesheet, depot.css, and put it in the same directory.6.”
You might want to explain what xhr stands for, might not be apparent at first.
In the code listing:
<%= t(‘errors.template.header’, :count=>@order.errors.size, :model=>t(‘activerecord.models.order’)) %>
should instead be:
<%= t(‘activerecord.errors.template.header’, :count=>@order.errors.size, :model=>t(‘activerecord.models.order’)) %>
Now it’s Rails final, not beta, and “gem install rails”
Should probably mention or use ~> when adding to gemfile
My generate scaffold command also had the lines
invoke stylesheets
create public/stylesheets/scaffold.css
at the end
(we’ll tart it up in a minute)
“Create a migration that copies the product price into the line item, and add_product method in the Cart model to capture the price whenever a new line item is created.”
The add_product method is there already, so it should read “Create a migration … and change the add_product method …”
There are 5 bullets at the top of the page, two of which end with ‘and’ and the rest that don’t. It just seems a little inconsistent that some do and some don’t connect to the next bullet.
It would be nice if you point to the lines of code that are supposed to be edited on notifier_test.rb
“You can force Rails to use WEBrick by providing
an option to the following command:”
should read
“You can force Rails to use WEBrick by providing
an option, like in the following command:”
or
“You can force Rails to use WEBrick by providing
an option to the rails command:”
“[2009-09-29 10:53:40] INFO WEBrick::HTTPServer#start: pid=6044 port=3000”
has all the text after the # in green, like a Ruby comment, but it’s not a Ruby comment
The functional test will fail if you don’t provide more specific instructions. Readers will get something similar to the following:
1) Failure:
test_buying_a_product(UserStoriesTest) [/test/integration/user_stories_test.rb:48]:
<“Sam Ruby <depot@example.com>”> expected but was
<“depot@example.com”>.
1) Failure:
test_buying_a_product(UserStoriesTest) [/test/integration/user_stories_test.rb:48]:
<“Sam Ruby <depot@example.com>”> expected but was
<“readername@domain.com”>.
The error is generated because the email address provided on notifier.rb (from page 199 and 200) doesn’t match the email address provided in the test. Also, if the reader enters only depot@example.com at the notifier.rb file, the test will also fail because it has to match exactly what’s on the test, that is, Sam Ruby <depot@example.com>
It might get even more confusing if the reader substitutes depot@example.com for their own email address.
I think this section needs to be addressed with more specific instructions.
Hello,
I am not sure that it is a bug in Rails 3 or not.
I just came back to Rails after a long break and I was refreshing my memory about before_filter.
You write in the book that the original action doesn’t run if the filter returns false or renders or redirect. This supposed to be as you say (based on google results) but based on my tests it is not.
class ClubsController < ApplicationController
before_filter :test
def index
logger.info ’ —- * index* —-’
@clubs = Club.all
respond_to do |format|
format.html # index.html.erb
format.xml { render :xml => @clubs }
end
end
protected
def test
logger.info ‘—- * filter* —-’
render text: ‘text’
return false
end
end
Log output for this:
Started GET “/clubs” for 127.0.0.1 at 2010-09-17 02:28:25 +0200
Processing by ClubsController#index as HTML
—- * filter* —-
Rendered text template (0.0ms)
Completed 200 OK in 13ms (Views: 13.0ms | ActiveRecord: 0.0ms)
Which is fine.
Now I remove the render text: line from the filter method.
The log putput will look like:
Started GET “/clubs” for 127.0.0.1 at 2010-09-17 02:27:23 +0200
Processing by ClubsController#index as HTML
—- * filter* —-
—- * index* —-
Club Load (0.0ms) SELECT “clubs”.* FROM “clubs”
Rendered clubs/index.html.erb within layouts/application (3.0ms)
Completed 200 OK in 17ms (Views: 6.0ms | ActiveRecord: 0.0ms)
As you see ‘return false’ simply didn’t stop the action. Is this a bug or a new feature in Rails 3?
I am using Gentoo, rvm, ruby 1.9.2, rails 3.0.0
Mage
Perhaps I missed a step somewhere, but I received the error that line_items is not a function for nil class when cart.line_items.empty? is called in application.html.erb after the Checkout button is clicked. I added
cart = current_cart in new method in the Orders controller to resolve the problem. Again, maybe I missed a step.
In the source code of the “first attempt” to hide the cart, this render command is used:
<%= render(:partial => “cart”, :object => cart) %>
It raises an exception. Instead <%= render(
cart) %> should be used, as in the code snippets before and after this one.
for the listing in the example file for line_items.yml, it has product: ruby, cart: one
for my generated version it has:
product_id = 1, and cart_id = 1.
I had thought I followed the instructions to the letter, not sure if I messed something up with my rake commands.
ruby 1.8.7 (2010-01-10 patchlevel 249) [i486-linux]
gem 1.3.7
Rails 3.0.0
on ubuntu 10.04 32
“Finding the cart at the start of each action is starting to get tedious; we’ll see how to remove this duplication later.”
A reference to a later page should be inserted here.
The second Play Time exercise doesn’t make sense to me: Since cart is not set in the orders_controller, the cart disappears from the sidebar as soon as the checkout process is started. Therefore the checkout button cannot be clicked again during checkout. The most simple solution would be to add "
cart = current_cart" to the “new” action on page 175.
The sample code for depot_s/app/views/users/index.html.erb
You should add an if statement before the notice paragraph, because if this is not done, there is a permanent gray rectangle with a red border on the users administration page.
es.yml
should be add_html: instead of just add:
index.html.erb
should be button_to t(‘.add_HTML’ instead of button_to t(‘.add’
The order_shipped method in notifier.rb has not been altered and thus does not expect an “order” parameter, making test_order_shipped fail.
The ‘from’ address in the tests should be ‘from@example.com’ as used in notifier.rb above, instead of ‘depot@example.com’.
“Without much code, and a few templates” sounds strange, should be e.g. “Without much code, and with just a few templates”
Missing “the”: “surveys entire Rails ecosystem” should read “surveys the entire Rails ecosystem”
“adding a links”
“have to changes” should read “have to change”
At the bottom of page 95, we have “(And three commands…”, and the top of page 96 we have “…with only four commands.”
I can’t get the atom feed to work, and I’m not seeing any error messages either. I simply get nothing. Including some information about how to deal with errors for a new format responder would be much appreciated.
“That means that we need to name our partial
_line_item.html.erb and place it the app/views/line_items directory” misses an ‘in’
-> “That means that we need to name our partial
_line_item.html.erb and place it in the app/views/line_items directory”
Top paragraph “we already call the error_messages_for helper…”. I believe that code was removed.
Task G download code references seem to be a bit off. References in the book move back and forth between depot_o and depot_p, and the actual dowload source code is sometimes out of sync with the book text.
“The default is to show 30 entries per page,” should be: “The default is to show 10 entries per page,”
Class Order lacks the discount property
require ‘active_record’
class Order < ActiveRecord::Base
end
order = Order.find(1)
order.discount = 0.5
order.save
This page mentions the h method, but I can’t find any reference to it anywhere else in the book. It’s not in the index either, nor is html_escape. I assume that this is related to the introduction of SafeBuffers in Rails 3 which maybe eliminates the need for h(), but the dangling reference here is rather cryptic.
You have the word “on” twice. “Configuring Rails Applications guide you generated with the rails doc:guides command on on page 281”.
You have “is” twice: “This is is useful for doing things like storing values from HTML forms into database rows.”
Mistyped “placeholders” as “placeholderis”.
“We do that by placing placeholderis of the form :name into the string, and by providing corresponding values in a hash…”
“we point our browser to http ://localhost/products/.” should be “we point our browser to http ://localhost:3000/products/.”
(both times without the white space in the URL)
The second sentence of the paragraph after the Adding Additional Actions subtitle reads “on page 187 we added an create an interface to allow people to fetch a list of people who bought any given product.”
It reads awkwardly because of the two “an”: “we added an create an interface”
app/views/users/index.html.erb needs notice code:
<% if notice %>
<%= notice %>
<% end %>
The URL provided in the footnote does not link to a page that describes a plugin for fkey migration helpers.
In the table at the bottom of the page, under the params column, you have an opening single quote and a closing double quote { :id => ’123" }
Maybe you meant to have either 2 single or 2 double quotes instead.
In the last section of code (product.rb), The second line:
has_many :line_items
is missing the small triangle indicating it is the added line of code.
In your screenshot of the sidebar cart you have the dark green background of the sidebar extend to cover the entire area behind the cart. I’m pretty sure I followed your instructions exactly and my cart overruns the dark green background. I tested both on Google Chrome and Mozilla Firefox. I apologize if this is user error.
You flag the PAYMENT_TYPES line as a new line in order.rb (with that yellow arrow), but you had us add it just the page before. Yellow flag should probably be removed.
In the sentence just below the figure, are you sure you want to say “sophistically advanced”? The word “sophistic” means “plausible but fallacious”…
Sentence " For example, if we generate my_app using the command rails new my_app, the top-level directory for our new application is shown in Figure 18.1, on page 281.." has two periods at end.
I just bought pdf version and having some problem to understand.
line_item =
cart.line_items.build(:product => product)
why we have :product=> product
line_items has :product_id not :product?
I can’t get it.
Please email me somebody to ulugbekov@hotmail.com
Thanks in advance
InSection 12.2, IterationG2:Atom Feeds,on page 187 we added
an create an interface to allow people to fetch a list of people who bought any given product.
Should be we added and created an interface
Figure 7.1 does not show a validation error even though the price is less than 0.01. My code did the same thing until I caught a typo in it (though the code in the book looks correct)
Bottom of the pdf
such as htmlatom or js;
should be
such as html atom or js;
At the end of 12.1, you say “Now that we’ve captured the order it is time to alert the ordering department. We will do that with feeds. Specifically, an Atom formatted feed of orders.”
But that’s not what we do next, instead we create an Atom feed of who’s ordered a specific book, which is something of a leap.
In the code listing for the Gemfile where we add will_paginate, the #START_HIGHLIGHT and #END_HIGHLIGHT comments are being displayed instead of highlighting the right line
“The generate script created two e-mail templates in app/views/order_mailer, one
for each action in the OrderMailer class.”
No it didn’t, it created two e-mail templates in app/views/notifier, one for each action in the Notifier class.
The RJS templates are now legacy with Rails 3.0. Could you please update this section with unobtrusive JS examples
?
In the following paragraph:
“We start by introducing you to a number of such dependencies, starting with the underlying templating engines that power views. Then we will do a explore
bundler which is the component that is used to manage dependencies. Finally, we will show how these pieces are put together using rack and rake.”
The sentence:
“Then we will do a explore bundler which is the component that is used to manage dependencies”
Should probably be:
“Then we will explore bundler which is the component that is used to manage dependencies”
“do a” has been removed.
The comment ’# optional task to reconfigure databases" should be probably above the task :seed
At the top of the page is a table which consists of “Class Name”, “Table Name”, “Class Name”, “Table Name”. The first set of headers is normal, but the second set is bold.
Also, it says “These rules reflect DHH’s philosophy”, but up until now it’s been described as Rails’ philosophy.
The code sample here contains:
#START_HIGHLIGHT
create db/migrate/20100301000010_create_discounts.rb
#END_HIGHLIGHT
rather than highlighting the right line.
Arguably homebrew (mxcl.github.com/homebrew/) is a better option for installing SQLite 3, MacPorts has several drawbacks. Additionally, more and more people are using rvm (rvm.beginrescueend.com) for installing ruby. Then I think that is worth to mention this as the preferred path rather than MacPorts
“sup-ports” rather than “supports”
#
#
Cannot find ‘gem ruby 3.0.1.pre’
Ref: Download depot_q/Gemfile; 12.3 Iteration G3: Pagination
Continuing through your Pragmatic Bookstore application comes to a halt without this gem.
Are the and comments supposed to be there? I don’t seem to recall those being in the previous beta versions of the book.
When I enter characters in the Price field I get the ‘Price is not a number’ message as expected but the price value gets changed to 0.0 as well. (I’m running Rails 3.0)
In the sample code of the “Generating the Scaffold” section of the depot example, there is a “\\” following Product that should be removed.
This is the .mobi location 1354-66
The popup parameter to link_to no longer works in Rails 3. I tried to link to a discussion of this but your spam police wouldn’t let me.
In the carts/show.html.erb another change has snuck in that isn’t immediately obvious - namely the change from h2 tags to a div with the class of ‘cart_title’. (I actually only noticed this in the next chapter when creating the cart partial.) Astute readers who make the change here will see a yucky display of the cart title because the style sheet on the next page hasn’t got a style for ‘cart_title’. I suggest you just change the div back to an h2 and then highlight the change from the h2 to the div in the next chapter.
After first moving the cart to the side-bar the formatting of the side-bar is pretty cactus - certainly not at all as it appears in Figure 11.1. Am I right in assuming you’ve changed the side width and main margin values? If so, please reflect that in the style-sheet changes and download on the previous page. (I seem to remember this caused me grief when I first worked through it in the second or third edition of the book.)
When moving the app to Ubuntu 10.04, in the second bullet point, I found I needed “RackEnv development” rather than “RailsEnv development” to change the database used. The explanation I found is that the config.ru file indicates that Passenger should treat the app as a Rack application as opposed to a rails application.
I also found that in Ubuntu, I didn’t have the will_paginate gem. I used a (probably inefficient) combination of sudo gem install and sudo gem update to fix this.
Attachment FU is a bit of a workaround (requires dependencies, a litle messy) - what are the chances of including a solution such as Paperclip in here?
Uploading images is such a core feature, I think it deserves a multiple solution approach. I understand that using plugins should be minimised - but such a core feature should have a simple solution documented.
I am no expert… but shouldn’t these lines be using => instead of =<?
<%= number_with_delimiter(12345678, :delimiter =< “_”) %>
12_345_678
<%= number_with_precision(50.0/3, :precision =< 2) %>
16.67
Where you say “And that’s it.”, it’s not quite. You’ve missed the email check - although you’ve included it in the full code listing. I suggest discussing it explicitly before the full code listing.
This one fails:
assert_equal ‘Sam Ruby <depot@example.com>’, mail[:from].value
It should be:
assert_equal ‘<depot@example.com>’, mail[:from].value
Oops! Ignore the previous error. It should have said:
This one fails:
assert_equal ‘Sam Ruby <depot@example.com>’, mail[:from].value
It should be:
assert_equal ‘depot@example.com’, mail[:from].value
The CartsController skip_before_filter call should specify :destroy rather than :delete.
The Add to cart button in Spanish does not appear with the correct characters. t(‘.add’) should be t(‘.add_html’) and the YAML files should be changed as well.
You need to insert the following before the ul element if you want the ‘body’ message to appear as shown in the figure:
<%= t(‘errors.template.body’) %>
Not sure what this is supposed to mean: “Rails also works on Ruby 1.9, though some of the examples had to be modified in order for this to work.”
What examples? The examples that come with Rails? The examples in this book? Should it say “… in order to work” instead of “in order for this to work”?
The code snippet at the bottom of page 95 is missing a bracket, which appears under the screen shot on page 96. So if you do a copy and paste of the code, you get an error because the bracket gets left out.
After adding Pagination in the Gemfile, and issuing the “bundle” command, I found I needed to stop and start the rails server for it to take effect. (Mac OS, Rails 3.0, Pagination 3.0.pre2, Ruby 1.8). If this is required, that would be a good add, because this is the first time I HAD to do that.
The sentence “While conventions keep to a minimum the amount of configuration required
for a Rails application, we did do a bit customization” should read “did do a bit of customization.”
Once you have changed the routes to use a locale, the user_stories_test integration stops working because some of the routes no longer work as they are written in the test. For example, the xml_http_request test:
xml_http_request :post, ‘/line_items’, :product_id => ruby_book.id
Must now go to /en/line_items (or you can insert the locale some other way) or else the line item is not created.
I think you need the word “or” in “either to create Rails
Metal applications, to use Rack Middlewares in your Rails application” inbetween the comma and the ‘to’.
Minor nit: Figure 2.3 has "
Hello, Rails!
" in the HEAD, but the browser screenshot immediately below it shows “Demo1” in the window’s titlebar.
should say “modify the pay type”, not “modify the discount”.
in the playtime section, there’s no need to modify the update function to accept confirmed password instead of a hashed password and a salt, it already accepts because of the shared partial.
The reference to the logger in the last paragraph points to the wrong page.
There’s mention of a “Parts” class that was supposedly done in the depot application, but I don’t recall that actually being there.
Based on the unit test created for this function later in the chapter, the validator for images should be case-insensitive.
Therefore, the image validator should read (added the “i” modifier immediately after the regex literal):
validates :image_url, :format => {
:with => %r{\\.(gif|jpg|png)$}i,
:message => ‘must be a URL for GIF, JPG or PNG image.’
}
I realize this chapter on Ruby can’t be thorough and you do a good job making that clear. However, speaking as a Rails AND Ruby newb, I can say that the too-brief section on blocks and “yield” isn’t working for me. You explain “yield” just a bit, but there are no example usages in the text. It’s implied in the iterator/block combinations but it needs to be explicit in order to be pedagogically useful. Otherwise, please consider adding a direct reference to some other resource that explains it more fully.
The summary claims that have used ActiveRecord outside the context of Rails, but I don’t think that section is in this chapter anymore/yet?
When I do a rake routes, all of the routes seem to have a name for me, not just the four with names shown here. Is this due to my setup being different (I did some of the extra exercises)?
assert_generates, assert_recognizes, and assert_routing all seem to be pretty similar in terms of what they test - do you think you could give some information or best practices about which you should use and when? That would help make this a lot clearer.
(It didn’t seem possible to report an erratum against the index so I reported it against this section on functional testing.)
In the index under Functional tests, it says “see also Test”, but when I look under Test, there is no mention of functional testing.
“Rails is ready even if the browser your users have installed are not” should use “is” and not “are” for the last verb, as “browser” is singular.
No comma is needed after the number 39 in “Finally, lines 39, and 44”.
Why not adding a chapter introducing Passenger 3 with its beautiful Passenger Lite that is much much better than WebBrick?
“tart” should be “start”
For now, lets write a trivial template (we’ll tart it up in a minute):
In the second bullet point “The first time through” should presumably be “The first time though”.
Hint: the pluralize helper (described on page 353)
should be page 356 in the pdf
“The first thing you should notice is that the file is considerably more smaller.”
should be changed to
“The first thing you should notice is that the file is considerably smaller.”
“By downloading one script and adding one few lines of javascript…”
should be
“By downloading one script and adding a few lines of javascript…”
“We won’t be using the sever in this section”
should be changed to
“We won’t be using the server in this section”
“using the sever in this section” should be “server”
“dots and pound signs…”. I know you mean #. Wikipedia defines pound sign as £. Most europeans probably think of £, certainly brits. Music lovers call a # a sharp, most programmers seem to call it a hash symbol.
In “Built-in Transactions” sections after words “When we discussed parent and child tables…”, a reference to Page 282 (“One-to-Many Relationships”) would be very helpful.
In the very beginning of section “Writing Our Own SQL”, it feels like a missing word where marked below:
The methods we have been looking at each contribute to the construction…
In sentence “The resources line caused seven new routes to be added our application.” — missing “to”, should read “… to be added to our application.”
I might just be dense or reading something incorrectly, but there are many references on p397 to ‘options’ set in the example depot_r/db/migrate/20100301000003_create_line_items.rb, such as “If you look at the line item migration in the preceding section, you might wonder
about the duplication between the two option parameters”, but I do not see any options parameters nor understand what it is talking about
The pictures do not show up on our products index page. I did download the pictures and place them in public/images diretory, but no dice. While tailing the develoment log, I get a routing error.
ActionController::RoutingError (No route matches “/images/ruby.jpg”):
In Rails 3 there is no support for actionwebservice and it would be nice to be described in book how to make simple Web services in Rails 3. Just some basic stuff.
Third paragraph of Chapter 25 (“Rails’ Dependencies”) starts as:
While this chapter goes a beyond your normal day-to-day activities…
“goes a beyond” should be just “goes beyond”.
I don’t think that the class << self idiom has been used to this point. If the goal is to create a class method, that has been done with self.method, which should be again used here for clarity and consistency in this introductory text. In any case, if class << self is used, it’s meaning should be explained.
“Note that in this case an explicit require of active_support is that active support has not been configured yet” — check the grammar of that fragment
This chapter would be great functional index for those who had read the book to come back to. The steps (like creating seed data) are all organized by function rather than alphabetically, which is great. All that is missing is the pointers to the page or section where, e.g., how to set up seed data, is discussed.
There is a period missing after the number 434 where it says “on page 434”.
Could you elaborate more on how stale? and fresh_when are used and how they’re different? I’m having a really hard time following the information listed here.
Using a whole page for this picture seems really excessive, I think you could make it a lot smaller.
> rails generate scaffold Product title:string description:text image_url:string price:decimal
Testing the application on a MySql db instead of bundled sqlite, results in a default decimal(10,0) column. Yes, we are supposed to work with sqlite in development environments, but what about moving to production? The application was created using
> rails new depot -d mysql
About Git.
I’m absolutely new to Git. What should I do to use Git?
Sign up online on something like Github? Install a package from repository? Install the Git ruby gem?
I first installed git package for ubuntu, immediately removed it for testing the Git rubygem first. In the end I figured out that i was supposed to install git package.
apt-get install git
price_must_be_at_least_a_cent is misnamed — it does not relate to the price (it relates to the balance) and it does not require the balance to be at least a cent (it only requires that it be non-negative)
Pages 311 And 312 describe routing, but are not referenced in the index under Routing
Actually, pages 311 - 322 are mostly about routing, and should be listed under Routing in the index
This page is almost totally empty in this version. I know the final one may not be like this, but this just looks odd.
The CreateLineItems migration example for the execute method doesn’t actually use execute…?
“we will create small script” needs to be “we will create a small script”
“We covered topic ranging from” should be “We covered topics ranging from”. “We covered migration an caching as” should be “We covered migration and caching as”.
It should be “an”, not “a” before “object” in sentence “The lambda operator converts a block into a object of type Proc.”
And that is all there is to it! The default is to show 30 entries per page….And that is all there is to it! The default is to show 10 entries per page
the second question in play time doesn’t make sense to me.
once “checkout” button is clicked, the cart disapears so there is no more checkout button to click…
The cache examples use the h() function twice, on pages 380 and 382. Is it appropriate to use h() in Rails 3?
Additionally, if you have a rails server up and running, restart it to pickup these changes.We
won’t be using the sever in this section, but will shortly.
sever should be server
“The third part of the book, starting on page 262, surveys entire Rails ecosys- tem.”
That should either end with “entire Rails ecosystems” or “the entire Rails ecosystem”.
To make the functional test pass, you have to also fix the fixture? My fixture contains
one: {}
Pages 423 & 424 also make reference to defining routing, so they should be in the index under Routing
The book says that there are two ways to define callbacks, one being “directly” by overwriting the method and the other by declaring handlers. I think the first way is what is now causing deprecation errors like “DEPRECATION WARNING: Base#before_create has been deprecated, please use Base.before_create :method instead.” I could easily be wrong since I’m fairly new to Rails, but I figured I would bring it to your attention in case this method should be dropped from the book.
Under “Selecting a Data Representation”, it says “… they should see a nicely formatted HTML.” A HTML? It sounds strange with the article there. Also, in the previous sentence, “human user uses” sounds a little funny.
bullet point NetBeans: remove hard hyphen from word “sup-ports”
bullet point 2, second paragraph: URL breaks justification
“will be seeing and modifying a number of controllers in the
development of the Depot application”
Has the Depot application been introduced yet? Should it read something like, “in the development of the Depot application (the sample application we’ll be building in this book”?
Should you introduce booleans in your introduction to ruby?
I think it would be useful to at least mention “unless” and “until” here.
users also need to be able to “destroy” line items.
“lineitem#destroy” should be added to the white list too.
class LineItemsController < ApplicationController
skip_before_filter :authorize, :only => [:create, :destroy]
from my limited understanding, I suspect we should have a:
“fixtures :products ”
line a the top of the tests class to ensure that the fixtures data is correctly used. If not, then it would be a good idea to explain why not.
There’s a footnote at the bottom of page 266 that talks about the Pragmatic Programmer store, but it took me far too long to realize that you meant the actual store and not the depot application used as a running example in the book. It would be nice if this could point to a code example somewhere online of using the lib directory.
Second paragraph is a run-on sentence with three independent clauses. Consider using different punctuation or breaking up into separate sentences.
<sanitize product.description>
should be:
<%= sanitize product.description %>
By the style guidelines you gave earlier, shouldn’t:
image_tag(product.image_url)
be:
image_tag product.image_url
?
Fresh/clean Macbook Air, the default path is not /opt:
for cmd in ruby irb gem rake; do which $cmd; done
/usr/bin/ruby
/usr/bin/irb
/usr/bin/gem
/usr/bin/rake
Time.zone = ‘Eastern Time (US & Canada)’ — should be & not &
application is spelled “appilcation” in the first paragraph on page 323.
… during the development of your appilcation, this is good…
update_attribute skips validation, and will save all attributes in a dirty record. It’s listed in the book next to update_attributES as if they can be easily interchanged which I think will catch some people out. For updating a single attribute I think update_attributes(:key => “value”) should be used instead.
Before the code snippet, should be “order controller” instead of “store controller”
For the initial unit test there are only five assertions performed and five successfully tested. The output on the page shows 6 assertions successfully tested.
Middle of the page: text refers to “map.resource” rather than the new-style “resources”. The code example is correct, however.
Middle of the page: text refers to “map.resources” rather than the new-style “resources”.
“The primary disadvantages of non-gem … gems is …” confusing.
In building the rescue handler for the controller from section E2, the “store_url” does not route by default at this point. I have run “rake routes” and there is only “store_index” at this point. Changing the redirect_to “root_url” solves this problem or one has to add the routes to routes.rb.
Here is my rake routes:
mkazmier$ rake routes
(in /Users/mkazmier/rails/depot)
line_items GET /line_items(.:format) {:action=>“index”, :controller=>“line_items”}
line_items POST /line_items(.:format) {:action=>“create”, :controller=>“line_items”}
new_line_item GET /line_items/new(.:format) {:action=>“new”, :controller=>“line_items”}
edit_line_item GET /line_items/:id/edit(.:format) {:action=>“edit”, :controller=>“line_items”}
line_item GET /line_items/:id(.:format) {:action=>“show”, :controller=>“line_items”}
line_item PUT /line_items/:id(.:format) {:action=>“update”, :controller=>“line_items”}
line_item DELETE /line_items/:id(.:format) {:action=>“destroy”, :controller=>“line_items”}
carts GET /carts(.:format) {:action=>“index”, :controller=>“carts”}
carts POST /carts(.:format) {:action=>“create”, :controller=>“carts”}
new_cart GET /carts/new(.:format) {:action=>“new”, :controller=>“carts”}
edit_cart GET /carts/:id/edit(.:format) {:action=>“edit”, :controller=>“carts”}
cart GET /carts/:id(.:format) {:action=>“show”, :controller=>“carts”}
cart PUT /carts/:id(.:format) {:action=>“update”, :controller=>“carts”}
cart DELETE /carts/:id(.:format) {:action=>“destroy”, :controller=>“carts”}
store_index GET /store/index(.:format) {:action=>“index”, :controller=>“store”}
products GET /products(.:format) {:action=>“index”, :controller=>“products”}
products POST /products(.:format) {:action=>“create”, :controller=>“products”}
new_product GET /products/new(.:format) {:action=>“new”, :controller=>“products”}
edit_product GET /products/:id/edit(.:format) {:action=>“edit”, :controller=>“products”}
product GET /products/:id(.:format) {:action=>“show”, :controller=>“products”}
product PUT /products/:id(.:format) {:action=>“update”, :controller=>“products”}
product DELETE /products/:id(.:format) {:action=>“destroy”, :controller=>“products”}
root /(.:format) {:action=>“index”, :controller=>“store”}
Thanks - love your books and the beta book process!
Misplaced possessive apostrophe in the second paragraph: “you can add to Rail’s understanding” should be “you can add to Rails’ understanding”.
Minor note: Triangles highlighting the changed code appear as ‘*’ (asterisks) in the ePub format, as displayed on a iOS iBooks app (iPad and iPhone 3GS tested).
To help new users, clarify that the Mac OSX SQLite 3 version checker is a Ruby program, e.g.
“You can verify which version […] is bound to by running the following as a [Ruby] stand-alone program:”
hello.html.erb changes are shown as only the last 3 lines, whereas all four lines have been edited.
In the assert_equal statement you’re using join(‘; ’). However, it is not immediately obvious why. I’m still u certain why it is required. Maybe you can add a line explaining it?
I believe the screenshot on this page is wrong. If the steps have been followed up to this point, a different style is used for the message (and it’s surrounded by the rest of the page).
To keep with the style you’ve been using so far in the book, shouldn’t it be:
@cart.line_items.each
instead of:
for item in @cart.line_items
?
Would it make sense at this point to mention the security considerations involved with storing the cart id in a session like this (if cookie session store is used, users can increment the cart id in their cookie to get another users’ cart)?
1.7 Claims “We (optionally) selected a version control system.” This is not true, while there is a small blurb about version control on page 32, we do not select one, we are not presented with options, and we are not given any instruction on how to use Git, the one version control mentioned. This may occur later in the text, but it does not occur in chapter 1, and suggesting such left me very confused and thinking I missed a major section. I reread the Version Control section on page 32 numerous times, and I certainly do not feel that I selected a version control system.
If you’re going to suggest MacPorts please provide steps for setting up and installing MacPorts.
seeds.rb creates the products in the order, wd4d, prog ruby 1.9, debug it
The image displayed on page 91 has the products listed in alphabetical order, or the reverse order from how they were entered into the db. There isn’t any code that was added that should have adjusted the order from how they were entered by seed.db that I could find.
For style:
current_item = LineItem.new(:product_id=>product_id)
should be:
current_item = LineItem.new(:product_id => product_id)
For someone learning rails, two things were unclear when changing the model here: 1) Why don’t you need to do current_item.save after updating the quantity? 2) Why do you have to append to line_items in the else case? Doesn’t .line_items look up the line items associated with the Cart on the fly?
To follow recommended Ruby style, should “for item in cart.line_items" be "
cart.line_items.each do |item|”?
For consistency, the key/value pairs in this page (3 of them) should be “key => value” not “key=>value”.
rm public/index.html should be git rm public/index.html if the student is using git version control as suggested earlier in the book.
I don’t want to spam this system so I’ll stop reporting every single one, but there are many places that use “for x in y” instead of “x.each do |y|”. It would probably make sense to standardize usage to either one or the other, unless the goal is to use both to get people comfortable with both styles.
The contents of the downloaded depot_b/db/seeds.rb differ from the code listing on this page (“Web Design for Developers” vs. “Programming Ruby”). A small point, but might confuse the reader.
A Readme file in the downloaded code root directory would help guide users as to which section matches which version of the depot application.
The application.html.erb code listing includes a ‘triangle’ marker to show a code change when no change has been made. This is the original unedited file.
Explain why .to_a is necessary here?
You might want to add price to the line_items table schema here, since you mentioned on page 78 that we’re jumping the gun a little bit and adding this to our schema early. I was confused by the first playtime on page 141 because I thought price had already been added to the table based on what I read on page 78.
If you follow these instructions after having done the playtime where you add a delete button to each line item, it looks pretty bad in the sidebar…
Wouldn’t you want to put the “format.js” in the else block too?
“Instead of a redirect, we expect a successful response containing call to replace” should be “…containing a call…”
Under Rails 3.0.1, Ruby 1.8.7 running on Mac OS/X 10.6.5, it appears that the redirect_to ignores the flash message when set as a :notice or :alert, and crashing when set as a :flash message, with:
undefined method `keys’ for Line item was successfully created.
The code in question is:
def create
cart = current_cart
product = Product.find(params[:product_id])
line_item = @cart.line_items.build(:product => product)
respond_to do |format|
if line_item.save
format.html { redirect_to(
line_item.cart,
:notice => ‘Line item was successfully created.’) }
I’m still working my way around RoR, but this would appear to be a bug in v3.0.1, from what I can deduce. Or have I done something wrong?
After clicking “Create User”, the index is redisplayed, but without the cheery flash notice. I see this has been mentioned for previous printings (B6 and B7).
errors[:base] is not explained (where is this error shown?)
The playtime things here are awfully hard to do for someone new to Rails with the tiiiiny introduction to Ajax in Rails that was given in this chapter (in contrast to the previous playtimes). I think I’ll stop doing the playtimes for the rest of the book and maybe try them after actually learning enough to do them.
Regarding comment #44286: I too found my AJAX implementation broken, and in the same way, down to a silly typo on my behalf. Instead of:
<%= button_to ‘Add to cart’,
line_items_path(:product_id => product),
:remote => true %>
.. I inadvertently included the :remote parameter in the line_items_path, like this:
<%= button_to ‘Add to cart’,
line_items_path(:product_id => product,
:remote => true) %>
I imagine this will be a common typo and the cause of a few frustrated debugging sessions. Perhaps a note on this would be of help?
Mind you, learnt a lot on how to troubleshoot by making these kind of mistakes… :-)
The _form partial differs from what is created by Rails 3.0.1, so I presume you want the reader to change it accordingly, but no triangles are displayed, and the text implies that the autogenerated _form will be used.
In other words, my suggestion is to either add triangles, explain that some modifications to the default _form are required, or both. :-)
<%= render ‘form’ %> has the wrong indenting
The line “PAYMENT_TYPES = [ ”Check“, ”Credit card“, ”Purchase order" ]" has already been added, so it doesn’t need a little arrow at the beginning of it.
In the StoreControllerTest, the regular expression to test for price will validate incorrect price values.
assert_select ‘.price’,/\\$[,\\d]+\\.\\d\\d/
This expression will match the invalid price string
“$,.00”
Here’s the description of how << affects foreign keys that I was confused about earlier in the book when this was done. Maybe this description should be moved up to the first time << is used to append to a collection of children.
You forgot to menthion other changed parts of depot_r/app/mailers/notifier.rb from depot_p/app/mailers/notifier.rb.
I had to download, look at the source code, and apply changes. Otherwise, the test in P. 191 will give you errors.
default :from => “from@example.com”
to
default :from => ‘Sam Ruby <depot@example.com>’
and
def order_shipped
@greeting = “Hi”
mail :to => “to@example.org”
end
to
def order_shipped(order)
@order = order
mail :to => order.email, :subject => ‘Pragmatic Store Order Shipped’
end
How about a quick (one or two sentence) description here of RSS and feeds and Atom, rather than assuming the reading knows what Atom feeds are?
When I follow the steps to this point and try to view the Atom feed, I get a 406 Not Acceptable in my logs and nothing returned to the browser.
You should mention that “bundle install” needs to be run as root.
“<%= render @order.line_items %>” is indented wrong
Some things required to make these tests pass were not mentioned earlier: updating the order_shipped method, changing the default from address, etc.
The book doesn’t mention what method in the new integration test file these lines should go in.
The email set up earlier was simply “<depot@example.com>”, not “Sam Ruby <depot@example.com>”, which makes this integration test fail.
The orders_controller_test.rb listing has a minor typo, as the end of file does not follow the “should create order” test, as suggested by the listing:
assert_redirected_to store_path
end
end
Perhaps replace the last ‘end’ with a #.. construct as used to show the missing code at the top, e.g.
assert_redirected_to store_path
end
# …
Second sentence under VIEW reads “By default, Rails scaffolding provides edit, index, new, and show, as well as a
partial named form that is shared between edit and show.” Shouldn’t the last word of this sentence be “new”?
First sentence under CONTROLLER reads “…one each for the five models, and the three additional ones FOR TO support the views…” which makes little grammatical sense.
In the seeds.rb file, image_url is in the format of ‘/images/image.jpg’. in the index, you show the images with image_tag(product.image_url).
The image_tag helper prepends ‘image/’ so the image urls were appearing as ‘images/images/ruby.jpg’ resulting in broken image links.
removing ‘images/’ from the image_url in the seeds.rb file.
You describe the encrypt_password method as “We’ll write this as a private class method.”, but this fails with a call to private method error, and besides, the full listing of user.rb on the following page shows it to be included as a public method.
Due to an error on my behalf, I forgot to add the “require ‘digest/sha2’” line to the model user.rb, yet the code still works.
Further testing shows the Digest::SHA2.hexdigest call to work within rails without the require statement.
So, if you forgive the pun, is the ‘require’ required at all?
The password= writer method described fails as written, as no encrypt_password method is defined for the class, but for the object.
In other words, the line:
self.hashed_password = self.class.encrypt_password( password, salt)
… fails, but works when rewritten as:
self.hashed_password = self.encrypt_password( password, salt)
Note also the full code listing for user.rb a couple of pages later, which has the same error.
You describe the encrypt_password method as “We’ll write this as a private class method.”, but this fails with a ‘call to private method’ error, and besides, the full listing of user.rb on the following page shows it to be included as a public method. So, suggest change to “We’ll write this as a public class method” instead.
There appears to be an extra unneeded blank line at the end of the set_i18n_locale_from_params method.
FYI, #45642 here is probably a duplicate of #45156, the one I ran across (406 Not Acceptable with nothing displayed in the browser). I tried debugging for a bit but couldn’t figure out how that HTTP code was returned instead of the expected feed.
I had a hiccup interpreting the rails generate command on p81 and believe it may be helpful to change the structure of that command so its obvious that there is no space between ‘\\’ and ‘title:string.’ A space results in compilation errors and db migration attempts.
As a newbie to RoR this feels better:
rails generate scaffold Product
\\title:string description:text image_url:string price:decimal
add in the Spanish translation needs to be named add_html because it contains an escaped ntilde character.
“<%= render ‘form’ %>” is indented wrong
“<raw msg>” should be “<%= raw msg %>”
I assume you’ll fix this, but “set password for ’some_user’@’some_host’ =OLD_PASSWORD(’newpwd’);.” runs into the margin.
“# optional task to reconfigure databases” This comment doesn’t make sense. The task below is doing a bundle install, but it’s described as reconfiguring databases?
Can the classes Employee and Person used in the example please be changed to something else?. Having Employee inheriting from Person looks like the old classic issue of modeling roles using inheritance instead of composition.
“Note that in this case an explicit require of active_support is that active support has not been configured yet, and that one of the configuration options that rails provides is to not include Active Support libraries at all”. Maybe it’s just the grammar that’s throwing me off (already mentioned), but I don’t even understand the point that’s being made about Active Support libraries being provided or not.
“The rails script is what is run when you run the rails command while inside the application directory.” This is redundant. On the previous page, you already said: “This directory also holds the rails script, itself. This is the script that is run when you run the rails command from the command line.”
orders = Order.find(:all) should be changed to
orders = Order.all as find(:all) has been deprecated and will be removed in version 3.2 of Rails.
“The next line verifies that there is a h3 element with the title of the Rails book that we had entered previously.” should read “The next line verifies that there is a h3 element with the title of the Ruby book that we had entered previously.”
Last paragraph on the page: in the sentence “…and rails uses these conventions”, “rails” should be capitalized.
In the paragraph starting “While we haven’t talked about the assign method to date…”, “assign” should read “assigns”.
A form_tag block has been added under the banner div in application.html.erb, but is not marked as a change (little triangles needed).
After making the changes to the YAML files, it may be worth repeating that a server restart is required for the translation to work.
The drop-down appears bang in the middle of the banner, as coded in the preceding application.html.erb, and looks horrid to my eyes. Plus, it is not displayed at all in Figure 15.3. I would suggest moving it to the bottom of the side div to maintain some visual sanity.
The contents of the form_tag addition on this page (236) already figure in the preceding code listing on PDF page 223-224. This corresponds with my previous errata submissions (#45753, #45757). Best to remove the code from the first page, as the explanation that follows in pp 236-237 introduces the change and fixes the layout.
In 2 places you list how to start the rails server. You say “rails server”. That will just create a new rails application. To start the server you enter “ruby script/server”.
In part of the installation instructions you mention “sudo port install rb-rubygem”. It should be “sudo port install rb-rubygems”. NOTE the added “s” on the rubygem.
The sql server date and time related mappings does not match for sql server 2008.
Sql Server 2008 supports addtional column types like date and time, and they are used by the sql server active record adapter(latest version 3.0.6) to map the rails time and date types.
rails type | sql server 2008 | sql server 2005 or 2000 |
:date | date | datetime |
:time | time | datetime |
I haven’t tested that for sql server 2005 and 2000 but I assume that it should be this way as it is in the book or in the table above. Sql server 2005 and 2000 doesn’t support the date and time type.
“Feel free to tailer this to your needs.” should be “Feel free to tailor this to your needs.”
In the line: “NetBeans IDE 6.5 (some url here) sup-ports Windows”, the word “sup-ports” needs to be “supports” without a dash in the middle of it.
Figure 7.1 should come after the closing “}”.
“We can use the model’s valid? and invalid? methods to see whether it validates, and we can use the any? method of the error list to see whether or not there is an error associated with a particular attribute.”
These don’t appear to be methods of the model but of product_test.rb. Perhaps you mean the “validates” methods of the model.
“…and we verify the error message associated with the price attribute is what we expect.”
It is not clear how one knows the error message one should expect here. It is not explicitly coded for the validation in product.rb (using “:message …”). Is it derived in some standard way from the statement:
“validates :price, :numericality => {:greater_than_or_equal_to => 0.01}” ?
“We’ll cover functional tests in more detail in Section 8.4, Iteration C4: Functional Testing of Controllers, on page 116. As for now, it is time for us to write some unit tests.”
It would be helpful somewhere in the previous section to include a brief description/differentiation of functional vs. unit testing.
There is a ) near the end of this line with no matching (
format.html { redirect_to(store_url,
:notice => ‘Your cart is currently empty’) }
After adding precision and scale to the price decimal, I tried adding a decimal like 45.2341 and it stayed the same (it didn’t cut the last two decimals to 45.23). I still haven’t figured it out, but I found someone else following the book having the same problem. If this is normal, I’d suggest you put in a side note explaining why it doesn’t work. If not, please fix it!
“Add the locale to the products column” should be something like
“Add a locale column to the products table.”
Might be too detailed to get into here, but I’m curious what the difference is between inflect.singular/plural and inflect.irregular (when do you need to do the case-insensitive regex and when can you just do inflect.irregular, like you did in your example?).
I still haven’t seen an explanation at this point of how exactly things like “cart.items << new_item” work. Does it update foreign keys? Or just append to an in-memory list?
“The next three lines verify that all of our products are displayed. The first verifies that there are three elements with a class name of entry inside the main portion of the page. The next line verifies that there is a h3 element with the title of the Rails book that we had entered previously. These assertions are based on the test data that we had put inside our fixtures:”
And the third line…?
“:limit methodname”… “methodname” should have a space, but even with a space it doesn’t make the most sense.
The “order(:id)” is confusing to me here. Why isn’t it “Order.find(id)”? What does lowercase “order” do?
“The :lock method” should say “The lock method”, following the convention that is used for all the other methods here.
121 has no erratum link so I’ll place it here…
“Rails makes the current session look like a hash to the controller, so we’ll store the cart in the session by indexing it with the symbol :cart_id.”
The first suggestion is that you place a brief description of what you mean by “store the cart in the session” here. By looking ahead to the sessions sections referenced on p.122 I was able to discover that you mean the actual contents of the cart are stored in the session info that is (presumably) shipped back and forth between client and server on every request (!).
The second suggestion is the explain the relationship/significance of the fact that a hash is used.
The third suggestion is that you explain why code is placed in application_controller.rb and not somewhere else. Although I have read ahead in the “Rails in Depth” section attempting to find out when this controller is used I was unsuccessful in finding an answer. I remain hopeful, however, that an answer will become readily apparent as I read on :).
“# Before saving or updating, encrypt the fields using the NSA and DHS approved Shift Cipher” That actually made me laugh out loud, but I’d hate to see someone take it seriously.
I just read “This example uses trivial encryption—you might want to beef it up before using this class for real.” You can ignore #45817 and keep the humor in :)
“#store .entry form, #store .entry form div {
display: inline;
}”
Does not seem to produce the desired formatting (on either Chrome or Firefox)
“As the build method is called on the @cart that will be used as one end of the relationship.” is a fragment…
Correction on previous comment. I think you want a comma after @cart in the following.
“As the build method is called on the @cart that will be used as one end of the relationship.”
we’ll tart it up in a minute
From the code listed on this page and judging by the code from a previous sample, this example seems to be wrong:
animals = %w( ant bee cat dog elk )
It should be:
animals = %w{ ant bee cat dog elk }
bottom of page
“affect any data that already exists” should be “affect any data that already exist”
(data is plural)
In the margin, yield -> page 64. This should be corrected to page 65 where yield is discussed.
The next line verifies that there is a h3 element with
the title of the Rails book that we had entered previously.
The book is a Ruby book, not a Rails book.
#store .entry form, #store .entry form div {
display: inline;
}
Ignore previous comment. I found my error :)
How about including details on model validation in the ActiveRecord section (in particular, how they’re stored and used by ActiveRecord)?
I’m curious at this point why id is referred to in the controller as “params[:id]” but format is simply “format”, even though they’re defined the same way in the route.
cleanup" should be "clean up
Iteration A1 - start a local server.
You may want to point out that you must start WEBrick in the depot directory. If you have previously run the demo in a separate console it’s really easy to restart WEBrick in the demo directory and get a - No route matches “/products” - error.
“15.2
Iteration J2: Translating the Store Front
Now it it time …”
I think that is “Now it is time”.
Ok?
Regards,
Paulo
HTTP menthod => HTTP method
For consistency with similar explanations, explain in the “port_string” section what its value is if the port is the default port?
Would it be worthwhile to mention remote_addr in addition to remote_ip?
Why mention erase_render_results here? If it’s undocumented, unrecommended, and should be used at your own risk, should you mention it at all? Or at least explain why someone would ever want to render twice per request.
Syntax for flash.now and flash.keep?
An example or two with real code here might be useful. The constant stream of text is a little heavy, and seems inconsistent with other sections where theory is interspersed with snippets of code for those of us who learn better by example.
It seems like there is minimal information on testing in this third section of the book. Maybe everything needed is sprinkled throughout, but it might be nice to see a little section on testing at the end of talking about Active Record, Action Controller, and Action View.
In this section (21.1), something I was expecting to see but didn’t was an explanation of <% , <= %> and <% -%>. In other words, a little blurb that says the template is interpreted and certain strings (explain which) that are found are interpreted and replaced like so…
Is “scalar” the right word to use here? I looked it up in the index of the pickaxe book and it’s not there.
Something weird going on with point #1 in the graphic. It looks like it says “to edit a userl.t reads the…”, but the rl.t are all smashed together.
Sorry for the multiple comments, but I realized there are lots of weirdly-displayed things in this graphic. It says “users controller .rb” instead of “user_controller.rb”, in #3, “HTML” and “to” are smashed together, in step #4 on the right the image looks distorted, the arrow pointing from #4 to #5 is distorted, etc. I tried with Adobe Reader on Linux and Windows.
Don’t know how nitpicky you want to be, but the example on page 347 says “form_for :model”, but the image on this page says “form_for(:user)” (different parentheses styles).
This is the only place in the book I’ve noticed <% -%> used instead of <% %>.
I thought the “h” method was not used in Rails 3.
“it’s invoked before filters are run”. The presence of absence of the apostrophe in that phrase completely changes the meaning… maybe reword it to be more clear?
It would be nice in this chapter to see an explanation of best practices for approaching implementation of caching in an application. For example, how should a small application start, what elements should be added as the site grows, how should it be determined where the best gains will be made by improving caching, etc.
Same as a previous point. Should h() be used in Rails 3?
Bottom of page, Note 1. Reads “…if you are managing your source code using git, you will want to use git rm index.html”
The command should be “… git rm store/index.html”
“The default is to show 30 entries per page…”
It should be “10 entries per page”, not “30 entries per page”.
I get the same problem as #45642. When I run “curl”, I get the feed just fine. But when I go to “/products/3/who_bought” in the browser to subscribe to the feed, nothing happens and I get the following in the server console:
Started GET “/products/3/who_bought” for 127.0.0.1 at Fri Dec 03 19:11:53 –0500 2010
Processing by ProductsController#who_bought as HTML
Parameters: {“id”=>“3”}
Product Load (0.2ms) SELECT `products`.* FROM `products` WHERE (`products`.`id` = 3) ORDER BY title LIMIT 1
Completed 406 Not Acceptable in 20ms
Sorry, #45884 is not a typo, the default is indeed 30.
Figure 2.3 filename displays as “say_controllerb”. Copy and pasted it it appears as “say_controlle.rb”. Should be “say_controller.rb” I think.
The link for download that code snippet is missing.
Also, the code doesn’t run. Rails gives an error. I believe it is where this call takes place:
<%= render(:partial => “cart_item”, :collection => cart.line_items) %>
Replacing this code with this:
<%= render(:partial => cart, :collection => cart.line_items) %>
Runs properly.
Show migration for HABTM?
Maybe it is somewhere in the book, but as newbie when you get to the section on HABTM, it mentions the join table, but doesn’t really describe the migration. I think it might be nice to show it.. esp since you need the :id => false. Pardon if it’s mentioned somewhere that I missed.
render(:json => stuff, [callback => hash] ) must be render(:json => stuff, [:callback => hash] )
see colon at :callback
Missing ‘s’ in sudo port install rb-rubygem
must be sudo port install rb-rubygems
The given code
resources :products, :shallow => true do resources :review
end
does not enable the recognition of the following routes:
/products/1/reviews => product_reviews_path(1) /reviews/2\t=> review_path(2)
Rails Version is 3.0.3
While following along with the Pagination section and carefully writing the code as instructed by the book, I found that it did not work. I would get an error while loading the index page for orders which complained that the paginate method was not found. After some time, I figured out that I needed to kill and restart the server.
“This third parameter also supports two additional options that modify the behavior of the link.” The only option I can see mentioned is :confirm. Was this paragraph meant to be above the previous one, where the :method option is described? Otherwise, what is this second additional option?
“Both can be found in the product index template:”
should be “Both can be found in the STORE index template:”
The code listing for views/orders/_form.html.erb does not internationalize name, email, and pay_type labels, so they end up being not translated, even though the screenshot on the next page does show translated.
Figure 14.3 should not show the enhancements to the sidebar (adding orders, products, users, logout) because those enhancements are not made until the next iteration.
This paragraph:
“Since we once again made use of HTML entities, we will want these error messages to be displayed as is (or in Rails parlance, raw):”
and the corresponding single line of sample code appears to be accidentally placed too high in the document. It seems like it was meant to come somewhere after the next paragraph, which introduces the discussion of error messages. It is confusing where it is placed now.
The image for Figure 15.8 is exactly the same as the image for figure 15.7. Figure 15.8 should show the words “name”, “address”, etc. all in spanish.
Highlighting “key words” or “Important words of the phrase” makes it more readable & easy to grasp.thanks Rajnish
Ruby Names
Local variables, method parameters, and method names should all start with a lowercase letter or with an underscore: order, line_item, and xr2000 are all valid. Instance variables (which we talk about on page 65) begin with an “at” sign (), such as
quantity and @product_id. The Ruby convention is to use underscores to separate words in a multiword method or variable name (so line_item is preferable to lineItem).
Class names, module names, and constants must start with an uppercase letter. By convention they use capitalization, rather than underscores, to distinguish the start of words within the name. Class names look like Object, PurchaseOrder, and LineItem.
Rails uses symbols to identify things. In particular, it uses them as keys when naming method parameters and looking things up in hashes.
For example:
redirect_to :action => “edit” , :id => params[:id]
As you can see, a symbol looks like a variable name, but it’s prefixed with a colon. Examples of symbols include :action, :line_items, and :id. You can think of symbols as string literals that are magically made into constants. Alternatively,you can consider the colon to mean “thing named” so :id is “the thing named id.”.
Almost halfway down the page, the book reads:
“Ruby statement modifiers are a useful shortcut if the body of an if, untilwhile or until statement is just a single expression.”
I think “untilwhile” should just be “while”
In the second sentence of the last paragraph, the second parenthetical statement contains two full sentences separated by a comma. A semicolon would be better:
“…and a method (this button does a POST operation; other common methods are GET, PUT, and DELETE).”
In the Figure 2.3 controller file name view as “say_controllerb” instead of “say_controller.rb”, but when this string is copy and paste the value is correct. This issue was mention when viewing pdf by Chrome 8.0.552.215 and Foxit READER 3.1.2.
I’m not sure PHP is best described as a web framework (“in other web frameworks, such as PHP or JSP”).
a minor but illustrative improvement on hidden_div_if():
def hidden_div_if(condition, attributes={}, &block)
if condition
attributes[‘style’] ||= ’’
attributes[‘style’] += ‘display: none;’
end
content_tag :div, attributes, &block
end
1) you introduce the idiom in the beginning of the book; here it is in action.
2) by applying “display:” additively, it covers more cases
3) leave it as an exercise to the reader to make it more robust (i.e. solve when the “display” attribute is already specified in the style).
The download link for show.html.erb comes back as html, not as text.
“The only tasks that remain are to initialize a database..”: Maybe substitute repository for database so as not to confuse the reader with the database created earlier in chapter.
“Note that you do not have to include the id column in test fixtures.” This is the first time the id column is mentioned; it was never explained.
After the “products attribute must not be empty” test:
you state that ‘two tests executed’ when your rake test:units output clearly shows one test executed.
These observations relate to server configuration, not Ruby on Rails and come from the perspective of a Linux newbie.
I have setup an Ubuntu 10.10 server and installed Ruby 1.9.2 and Rails 3.0.3.
1. Public key generation description implies that key generation is done on the server whereas it should be done on the client and copied to the server.
2. No description for installing Apache2, rake or rack.
3. Apache 2 config should not contain the directive NameVitualHost. This is already in ports.conf and the reference should be deleted or made clear its in ports.conf
4. The httpd.conf file should be edited to include “ServerName localhost” and the DocumentRoot.
5. Apache2.conf should not contain the virtualhost block as best poractice would be to create a file for each domain such as mydomain.com and www.mydomain.com in sites-available. Then issue the command sudo a2ensite mydomain.com to enable the site.
6. The rails application should ideally be placed in a common directory such as /var/www/myapp rather than a home directory and then issue sudo chown myapp user to give write permissions to udate the code.
7. sshd_conf does not need to be edited. Any editing is outside the scope of this book as it will work without editing.
8. On my machine, at least the capistrano script hung on bundle install as bundle asked for a password but the script did not ask for input. I had to comment out the bundle part of the script and load the gems manually.
8. I suggest that postgres install should be mentioned in addition to mysql and that the need to install libpq-dev before gem install pg be included.
Seasoned linux users may gloss over some of these details but they are a minefield for newbie users such as myself. Thanks for a wonderful book!
…and one set of for when…
…with code to which causes…
“…in the rails server window…”: Rails is not capitalized.
i’m using the iPad version: pg 133
near the top is: ..“similar layout-the designer”..
I believe this to be a typographic error as the “-” between ‘layout’ and ‘the’ is unnecessary
There are references to single table inheritance on this page and also in the index but it looks like STI has not been covered yet. Is this an over sight?
In the paragraph introducing the code to add to order.rb, “line item” should be plural. That is, change “…indicating that the line item that belong to an order…” to “…indicating that the line items that belong to an order…”
insert a link to download the logo image (logo.png)
line 12 - image_tag
untilwhile" in the middle part should be "while
On the the graph, the relationship between Order and Line Item is confusing. 1..n should be from Order to Line Item not the reverse.
In the code example that begins on p.225 and extends onto p.226, there is block of 13 lines that are marked with triangles indicating that those lines have changed. I can see how the first 4 lines have changed, but the remaining lines in the block appear not to have changed from what was there before.
in paragraph “Why test against 1 cent, rather than zero? Well, it’s possible to enter a number such as 0.001 into this field”
The number should be 0.01 rather than 0.001
“logoff” should be “logout”.
Concern of @line_item.save
Maybe I am a little bit picky, but there is a rare case that if the same use logs in to the website in 2 different sessions, it may cause dirty read problem.
It is necessary to do dirty read check so that the value must not be changed since it was retrieved.
Concern of @line_item.save
Maybe I am a little bit picky, but there is a rare case that if the same use logs in to the website in 2 different sessions, it may cause dirty read problem.
It is necessary to do dirty read check so that the value must not be changed since it was retrieved.
Duplicated [Empty cart] button. The button should be removed from depot_j/app/views/carts/show.html.erb
It is obvious that the Total is wrong in the image.
It should be 184.9*2 = 369.80
As written:
scope :last_n_days, lambda do |days|
where(‘updated < ?’, days)
end
gives a runtime error “in `lambda’: tried to create Proc object without a block (ArgumentError)”
Correct form is
scope :last_n_days, lambda { |days| where(‘updated < ?’, days) }
once we have passing tests.
(consider) once we have passed the tests. (or something so verb is correctly used)
Bit new to the subject (hence the book) but shouldn’t line_items be using :through to establish it’s has_many relationships. It seems this would lead to cleaner code in several cases.
Figure 12.1 has an arrow indicating @order.name maps to the :name attribute on the label and this is why the text box contains Dave. I believe the mapping should be to the :name attribute on the text_field instead.
<%= stylesheet_link_tag :all %> in application.html.erb
doesn’t add depot.css to the css’s resulting in no alternating background colors.
here is a snippet of the html code generated:
Depot
.
.
.
depost.css lives in the depot.db folder presently, if I copy it to the depot.stylesheets folder no change occurs to the generated html code (only scaffold.css is contained within :all).
Please withdraw my previous submittal re: depot.css. Evidently I didn’t have depot.css in the correct folder. Now rails generates the following HTML as it should:
Depot
and the alternating colors work fine now.
Hope I found this before I wasted your time.
Respectfully,
Capitalize “rails”.
Developers are worried about deployment, too.
remove the comma. it is not needed.
=> Developers are worried about deployment too.
Line 1. “Ruby on Rails is a framework that makes it easier to develop, deploy, and maintain web applications.”
I suggest you remove the comma after deploy.
=> Ruby on Rails is a framework that makes it easier to develop, deploy and maintain web applications.
In reading (and re-reading) about adding the fixtures directive in test/unit/product_test.rb it is not clear to someone new to Rails why. I see a lot of “Rails is already doing this” and if “The name of the fixture file determines the table that is loaded, so using :products will cause the products.yml fixture file to be used.” seems like the fixture file will already be loaded based on it’s name. MY SUGGESTION: Explicitly tell/show what will happen with & without this directive being in place. (or is this directive redundant to what will be automatically done by Rails. BTW great book!!!!
‘The products method indexes into “that” table. We need to change the index used to match the name we gave in the fixture.’ By the time we get to this paragraph it is not a clear tie to which “that” table refers.
Capitalize rails in “sending e-mail in rails”.
Capitalize html in “create html formatted e-mails”.
Under “Live Code”, you mention that links can be clicked to display code. This worked great in Safari, for Ruby files, until recently - now it will download the file instead of displaying it. Anyone know a way to change this? If there’s a solution, maybe it could go in the book - the feature is so convenient I feel lost without it :)
Playtime #2 suggests playing with the various options of the number_to_currency method, but the first one I tried (:locale => :fr - taken from the API documentation) doesn’t change anything for me - the currency amounts are still shown in dollars (my locale is US). I’m using Rails 3.0.1 and Ruby 1.9.2. [The other options shown in the API docs DO work, BTW.]
The host machine and development machine might have different versions of ruby.
Address the problem of getting these synchronized. I think there’s nothing for it but to do a ruby
install on the host. Then there’s the problem of ensuring that the passenger apache plugin picks-up the
right ruby version. How does that work?
If the ruby versions are different, then bundler and gems will not create an image that is portable from
the development machine to the host machine.
Even if the ruby versions are the same, some gems install machine specific native extensions. One such gem is mysql2, I think. The
image created by the bundler on the development machine is incompatible with the host machine.
Bundler must run install on the host machine to make that installation whole. Capistrano can help
execute that task.
Gemfile.lock seems helpful for locking versions. The vendor/bundle, vendor/cache breaks because even
the same version of a gem can install differently on different machines in different environments. Am I
wrong about that?
How do you ensure that the cgi program or passenger module run rails with RAILS_ENV set to “production”?
I don’t think it is sufficient to add that setting to .bashrc or .bash_profile.
How does ‘bundle install’ interpret the development, test, and production environments of Gemfile? Does
it install everything? How about ‘bundle pack’? (But the lock file production of ‘bundle pack’
is likely the only useful effect.)
My attempt at following along with the Task K deployment chapter has resulted in the output from ‘cap
deploy:migrate’ reproduced below. After over a day of poking-about for the solution,
the above observations aren’t helping me. Perhaps they are getting in the way?
I do know that developing a small sample application on the host machine according to the host
provider’s instructions did work. Now I’m working to discover the differences.
* executing “cd /home/user/domain/releases/20101228015253; rake RAILS_ENV=production
db:migrate”
servers: [“domain”]
[domain] executing command
* [err :: domain] Could not find sqlite3-ruby-1.3.2 in any of the sources
* [err :: domain] Try running `bundle install`.
command finished
My host provider wanted:
gem ‘mysql2’
and
adapter: mysql2
There were some differences in the other database.yml settings as well, such as reconnect:true
So as you say, “something like”
In the switch from views/carts/show.html.erb showing an unordered list to a table, the loop changes from
“cart.line_items.each do |item|" (crf. p128 & p131) to
"for item in
cart.line_items” (also on p144). Both technically work, but the more Ruby-ish “.each do |item|” should probably be used throughout (until OBE by the creation of the partial).
“We use the current_cart method we implemented on PAGE 121 to find (or cre- ate) a cart in the session.”
referenced code is now on pg 122.
First full paragraph, second sentence reads “We recommend that you start by vising the rubyonrails…” - missing a “t” in “vising”.
app/controller/line_items_controller.rb should be app/controllers/line_items_controller.rb
when moving on to partials the @ is missing from the cart object on
td class=“total_cell”><%= number_to_currency(cart.total_price) %>
making the application throw a siyntax error on the code highlighted fro _cart.html.erb
right line should read
td class=“total_cell”><%= number_to_currency(@cart.total_price) %>
great book otherwise. I find a few errors that take me a while to get throught -like why is the @cart variable being destroyed when I got to te application view? anwyay thx, m
There is already an error submitted for this piece of code, however it misses the point. The version of the cart partial, ie _cart.html.erb on page 155 is plain wrong. if you follow the book all along, the last version of _cart was created on page 146 and it does not contain “:partial =>”line_item" ….." the line is instead “<%= render(@cart.line_items) %>”.
I ask, is this some kind of error from the last version of Rails?
Manuel
sudo port install rb-rubygems (instead of rb-rubygem, missing an s)
In the following paragraph you are referring to the “line item migration in the preceding section” but the preceding section does not actually have a line item migration.
“Extending Migrations
If you look at the line item migration in the preceding section, you might wonder
about the duplication between the two option parameters.”
In the code in section 10.1, some of the key/value hashes lack spaces….like these:
LineItem.create :cart_id=>lineitem.cart_id,
:product_id=>lineitem.product_id, :quantity=>1
As a newbie, it starts an internal conversation: "Are these a different kind of hash? Do these non-spcaed hashes mean something else…something that hasn’t been explained.
So, you might want to examine and/or reconsider. Thx!
The tutorial begins to get a bit fuzzy in this section regarding what is a public method and what is a private method. Only way to determine proper placement is to look at the downloaded code.
Text describes that the reader will see two tests executed after running rake test:units, however, the sample output shows 1 test executed (as if we removed the original “the truth” unit test).
Malachy O’Connell’s suggestion to remove the , after the word deploy on p19 line 1, is not an optional comma. Don’t remove it.
In version 3 of the book, there was a great part under dynamic content that is quiet important, I do not know if it was moved to another part of the book I haven’t yet gotten to, but it should be a must have. It’s the section that discusses the use of when to use/not to use = sign after the <% and why to use the - sign before %>.
Near the top of the page: “We then pass that product we found in to @cart.line_items.build” should have “into” instead of “in to”
Why would you hide the cart on all pages and do the silly cart = current_cart statement in all of your controllers if you could just add a before_filter to set
cart in the application_controller?
before_filter :current_cart
private
def current_cart
cart ||= Cart.find(session[:cart_id])
rescue ActiveRecord::RecordNotFound
cart = Cart.create
session[:cart_id] = cart.id
@cart
end
Sam’s response to #45881 is incorrect. It should be ‘git rm public/index.html’.
In the end of page 96 begins validation, and after image on page 97 is “}”, would be nicer if its together
9.1 modifies the ApplicationController for the first time. It would help us nubs to have a sentence or two of introduction as to the effect of adding code here.
Also, the protect_from_forgery could use a brief mention.
(PS - Great book so far — thanks!)
I don’t see anything on rvm management of ruby,rails,.. environments. This is useful stuff.
Do you really mean ‘sudo gem uninstall rubygems-update’ in paragraph 1.2?
Broken link near “Find more options at …”
The topic DeploymentTips does not exist on wiki.rubyonrails.com.
Under Instantiating Observers, it says “you need to list them in your application’s environment.rb file (in the config directory)” when it should say “you need to list them in your application’s APPLICATION.RB file (in the config directory)”
I found the modification of the line items test fixture to be confusing. Before modification the fixture records have the keys ‘product_id’ and ‘cart_id’. The book modifies the fixture records keys to ‘product’ and ‘cart’. I find this change in keys without explanation to be a source of confusion.
Middle of page… app/mailer should be app/mailers.
On the first paragraph of section 16.2 Iteration K2, the first line reads:
“If you have are a large shop …”
but should read:
“If you are a large shop …”
Towards the middle of the page, ‘session#create’ should be ‘sessions#create’ as the controller class name is sessions.
I stumbled over the use of “relations” in the line “Relations are equivalent to an anonymous scope:”. Perhaps my issue is due to not reading enough of the preceding text, but it seems like you are using the word “relations” where you mean to use the word “scope”.
Gemfile contains:
gem ‘rails’, ‘3.0.4’
what may result in following Error:
Could not find gem ‘rails (= 3.0.4, runtime)’ in any of the gem sources listed in your Gemfile.
Solution: Either change the Gemfile version to 3.0.3 Or upgrade your System to RoR 3.0.4 (apparently a repeated application of instructions from the beginning of the book does not leverage Mac Users version from 3.0.3 to 3.0.4 yet …)
$ cat /.ssh/id_dsa.pub >>/.ssh/authorized_keys2
Suggest adding some way to update known_hosts so cap doesn’t get hung up on the authentication prompt.
In section 5.2, subsection “Use Cases”, right in the first sentence:
A use caseis simply…..
Should be a space after “case” and before “is”.
Minor niggle - “LineItem”.underscore => “line_item”
This line of code:
LineItem.where(“quantity>1”).each do |lineitem|
should probably be:
LineItem.where(“quantity>1”).each do |line_item|
There is a missing space.
First sentence, second paragraph. After “interpolation”
“Second, Ruby performs expression interpolationin double-quoted strings”.
Right at the beginning of paragraph 4, :presence => truetells…
Should be a space between the word “true” and “tells”.
In paragraph 5, second sentence:
We’ll use the delightfully named numericalityoption to verify…..
Should be a space between the words “numericality” and “option”.
Paragraph 5, sentence 3:
… verbosely named :greater_than_or_equal_tooption a value….
Should be a space between “:greater_than_or_equal_to” and “option”.
It is not clear what to install from the SQLite download page.
“Next, install SQLite3.2 Download and unzip two precompiled binaries for Windows:” could be rephased to “Next, install SQLite3.2 Scroll down to ‘Precompiled Binaries For Windows’ Download and unzip two precompiled binaries for Windows:”
When I entered the code “redirect_to store_url” I was prompted with a message saying that there was no store_url or neither store_url attribute. I changed to this :
flash[:notice] = “invalid cart”
redirect_to :controller => ‘store’, :action => ‘index’
and it worked fine.
I’m new to Rails and I might have made some mistake. Since I’m learning Rails with this book.
In section 8.3, it describes a change to the “index template”, but doesn’t specify a filename like the other sections do, when discussing changes to files (the file is in app/views/store/index.html.erb)
It’s also not formatted like those other sections with a filename, code listing, and an arrow identifying the changed line.
product_test.rb
trying to enter a negative price returns a different error message
product.price = –1
assert_equal “must be greater than or equal to 0.01” … fails
error message generated is: “is not a number”
ruby1.9.2-p136
‘ifexcept’ and ‘untilis’ should each be made into two separate words.
store_url for the redirection didn’t work for me. I’ve used “redirect_to :controller=> :store, :action => :index” instead.
Shouldn’t it be “A .js.rjs template” ?
redirect_to store_url, :notice => “Your cart is empty”
return didn’t work for me. I’ve used redirect :controller => :index instead.
In part II, you iteratively “build” an application
looks like this should this read as …
In part II, you iteratively “built” an application
There’s a great deal of web information about CMS’s to manage ‘static’ content i.e. a non technical client wanting to occasionally change a few web site details, as opposed to adding a new book (application data) to the worked example provided. Some recommendation on how to allow users to change content would be useful as a CMS like Radient or Refinery seems to be against the grain with the RoR framework.
Need a “changed” triangle at the line near the end of the page beginning “assert_redirected_to product_path(…”
35c35
< assert_redirected_to product_path(assigns(:product))
—-
> assert_response :success
The book is pretty clear, but I can’t make heads or tails out of the “Playtime” section of the website for ch10. This also happened in Ch9.
Could there be some kind of visual indicator of which submitted solutions are better and why? Because I’m learning, having a badge by the names, to identify a moderator, or the best solution, would help me understand better, and notice the differences.
Think Yahoo answers, where at least there’s an indicator to let you know which answer won.
Otherwise, seeing all the opinions from different students just confuses me.
On the side note it reads ‘lamdba -> page 71’ where it should read ‘lambda’
Last Paragraph re. phrase “nil is an object, just like any other, that happens to represent nothing.” This phrase is useless and explains nothing. Objects do not “represent” anything. nil is an object with a specialized behavior which can be described.
The right parenthesis to the “Note: …” is missing.
Missing space between second and third word of paragraph which begins with: “The :partialparameter”
Included with Rails is a number of JavaScript libraries.
should read
Included with Rails are a number of JavaScript libraries.
In the line “The rails generate command logs…” the word “nothing” lacks an h.
If you are using RVM for managing your Ruby version(s), I recommend reading the “Configure the Web Server” section of the RVM website (integration/passenger page).
This should avoid any “no such file to load — bundler” error messages from Passenger.
The other [Empty cart] button is in depot_j/app/views/carts/_cart.html.erb, which duplicates that in depot_j/app/views/carts/show.html.erb
Some of the code extracts in Rails in depth section look like they should be runnable in the example cart system built earlier, but can’t, eg:
PAGE 295:
result = Order.group(:state). order(“max(amount) desc”).limit(3)
It looks like the state column was in an older version of the system, can be confusing when trying things out
Use Cases
A use caseis
Should be
A use case is
MySQL is not included on all versions of OS X. (At least not on my late-2010 MacBook Air.)
sqlite3-ruby gem is now sqlite3, so I think better if we address this
gem install sqlite3
On page 194, the integration test file
user_stories_test.rb
generated by
rails generate integration_test user_stories
reads:
require ‘test_helper’
class UserStoriesTest < ActionController::IntegrationTest
…
But when I look at the file generated by the command in textmate it reads:
require ‘test_helper’
class UserStoriesTest < ActionDispatch::IntegrationTest
…
< ActionController::IntegrationTest
vs.
< ActionDispatch::IntegrationTest
Do you guys get the same result?
Best,
F
There are missing yellow > characters for the lines that are changed in the file depot_r/app/views/users/index.html.erb. Only arrows are shows for lines that have been added near the top of the file.
In the rails console example command, the following section is rendered in the incorrect color (should be maroon indicating command input, not blue for command output):
:password_confirmation => ‘secret’)
In the second paragraph, first sentence, there should be a space between the words “default_url_options” and “also”
I have been following along in the book, and most things are explained really well. I usually feel comfortable and understand what is happening as we do it. In this part, I realize that rake test threw a few errors, but what do they mean? Why are they happening? How does this piece of code that we added make a difference. I just have no idea what just happened. When I am coding in the real world, I won’t be able to just download a piece of code and throw it in. We need to know why things are happening and how we fix it.
Missing whitespace in Block lambda and require betweet methodname and description
Regarding booleans in databases this page reads:
“In the case of Boolean, it turns out that not all databases have a native boolean type. In the case of MySQL, a value of 0 is used for false, and a value of 1 is used for true. Unfortunately, Ruby treats everything that is not false or nil as true, so direct usage of these values is problematic.”
In the old days the raw attribute reader returned an integer, but nowadays the value is converted to a boolean (by default, there’s a configuration flag that may disable the conversion). So the user has no access to the integers in practice, and thus direct usage is no longer problematic (although it is not idiomatic).
May I suggest to weaken or obviate that part?
The rest of the explanation introduces predicates (appending a question mark to the attribute name), and it is fine.
To make the ajax call work I had to change the line from:
format.js
to:
format.js { render :layout => false }
or else the javascript code would have been returned to the browser incapsulated into the #main div of the layout (not valid javascript code). I don’t know if it’s a typo in the book or a bug in rails3.
“MIME type you’d like returned”.
Shouldn’t it be “MIME type you’d like to be returned ?”
At the top of the page the following code sample seems wrong:
verbose_greet(“Dave”, “loyal customer”) { puts “Hi” }
Instead of listing variable names for the accepted parameters it has actual strings as if this was a method call, not a method definition.
“In here you place static (in other words, unchanging) web pages, such as stylesheets, JavaScript, and perhaps even some web pages.”
Repetition of web pages.
Shouldn’t link_to for the :delete be button_to since it is a destructive action? In IE the confirmation would come up, but was ignored (cancel ->deleted). Changing to button_to resolved.
For the coded example at the bottom of the page the ending “}” is not showed until after Figure 1.7. I would make sure that is stays with the code example to stop any confusion.
Par. 1, sen. 1 reads:
“Note that when we removed the _id suffix from the attribute name.”
Need to strike the word ‘when’.
“Note that we removed the _id suffix from the attribute name.”
I think the source code of the demo application should build up sequentially. But here the functional test is taken from depot_g, while the examples before and after are taken from depot_f. The functional test should move to depot_f to be in line.
In the discussion of sorting (aka order) this is done on the Order table so I initially thought the Order.where(…).order(“”) was doing something on an order object as opposed to a sort. May be better to use a different table such as Product.where(…).order("title, DESC) to not overload the meaning of order in the example.
The brief sections on joins and groups are useless as they stand unless you know SQL. Maybe I am expecting too much but being able to find related records from other tables to the entries you have found in the main table seems fairly fundamental - I suspect this is what join is trying to do but this one paragraph fails to give me any idea how to do this.
This code from the deploy.rb file I believe is outdated:
after “deploy:update_code”, :bundle_install
desc “install the necessary prerequisites”
task :bundle_install, :roles => :app do
run “cd #{release_path} && bundle install”
end
In any case, it does not seem to work. The forums suggest that removing this and inserting:
require “bundler/capistrano”
is the correct statement.
I should note that this is not working for me. I continue to get an error preventing bundle install from working.
Thanks.
products should be
product in views/store/index.html.erb (line 7)
The line “@product = products(:one)” I believe requires that the file text/fixtures/products.yml be filled with data though that isn’t described and done until pg 103-104. products(:one) is a call to “row” :one in that fixture file. I’m converting all of the testing to rspec but that line confused me until I got to the bottom of page 103.
The example shows an initial price of 49.5 Then $5 is taken off. The image shows a price of $24.95 and the wrong book title. ??
The magic shown in the bottom half of the page needs some tweeking of the Gemfile - if the database in Depot is not the default (sqlite3)
The path to the hosts file in windows is wrong. It should be c:/windows/system32/… and not c:/system32/…
Very good book. Kind regards
“We can see the mapping between SQL types and their Ruby representation in Figure 19.1, on the following page.” Figure 19.1 is on the same page, not the following page.
“everything that is not false or nil as true”. Wrong font used for “true” (the code font should be used, but the normal italic font is used instead)
“In the Depot application. LineItems have direct relationships […]” There should be a comma after the word “application”, not a period.
In db/migrations/xxxxcombine_items_in_cart.rb on pages 132/133 of pdf.
Spaces need to be added around “=>” in lines like:
. . .
sums.each do |product_id, quantity|
if quantity > 1
# remove individual items
cart.line_items.where(:product_id=>product_id).delete_all
# replace with a single item
cart.line_items.create(:product_id=>product_id, :quantity=>quantity)
end
. . .
lineitem.quantity.times do
LineItem.create :cart_id=>lineitem.cart_id,
:product_id=>lineitem.product_id, :quantity=>1
end
. . .
As written w/o spaces, they didn’t work for me.
You cover destroy methods on this page but there are no examples of how to destroy related records.
It would be really usefull to show for example how to delete all orders related to a product that have been cancelled to show how active record relationships can be destroyed with conditions
I’m on Snow Leopard and I got sqlite3 stuff going but I ended up messing around with this until I got it. Don’t remember specifics but of everything so far (on page 100) 1.2 was the biggest ‘hiccup’. You might have someone do a sanity check that a simpleton like me will blow through this with Snow Leopard. I can’t remember my issues but this was my only wtf page so far.
“/users, /user/1” should read “/users, /users/1”
“Some controllers can be resourced based” should read “Some controllers can be resource based”.
“If it doesn’t find one and the controller implements the method_missing, that method is called […]”, suggest replacing with “”If it doesn’t find one and the controller implements method_missing, that method is called […]" or “If it doesn’t find one and the controller implements the method_missing method, that method is called […]”
“So will the following (as the default action of a controller is to call render if the action doesn’t)” is a little confusing… maybe replace with something like “So will the following (as the default behavior of a controller is to call render if the action doesn’t)”
“If the template needs instance variables, these must be set up by the method that calls the render.” should probably end in either “[…] calls render” or “[…] calls the render method”
<%= @page_title || “Pragmatic Store” %>
appears without any introduction.
“Because we’re in the store controller, we edit the file store_helper.rb in app/helpers (as shown on the next page)”. This is not shown on the next page, but rather immediately after that paragraph, on the same page.
instead of the for loop
for cmd in ; do which $cmd; done
a simple
which ruby irb gem rake
shows the same info and is easier to understand to non shell users
Section 26.4, start of second paragraph:
“Let’s look at at the RJS” => “Let’s look at the RJS”
Section entitled: “A Real Unit Test”, about halfway down:
“Replace the the truth test with” => “Replace the truth test with”
Page 157 says “We’ll write our helper so that it is local to the store controller by adding it to application_helper.rb in the app/helpers directory:”
Shouldn’t it say “We’ll write our helper so that it is local to the store controller by adding it to store_helper.rb in the app/helpers directory:”?
Page 160 says “We used :remote => true to invoke the LineItem.new action using Ajax.”
Shouldn’t it say “We used :remote => true to invoke the LineItem.create action using Ajax.”?
typing sudo gem install sqlite3-ruby, gives the following messgae::
Hello! The sqlite3-ruby gem has changed it’s name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
Thanks from the Ruby sqlite3 team!
work> rails new depot
has to spaces to the left of “rails”.
depot> rake db:seed
has two spaces to the left of “rake”.
In the last but one paragraph: “but here ActiveSupport is combining a class method”.
“ActiveSupport” would be “Active Support”.
As per the general style in ERb templates used in the book, “<sanitize product.description>” lacks a space to the right of the equal sign.
The rationale given for using a helper instead of “sprintf(”$%0.02f“, product.price)” is potential i18n.
This is a very distant risk. May I suggest saying instead that it is likely that depot will need to display the price of a product in several places, and wouldn’t be a good practice to repeat the format of a price all over the views. That is: introduce a helper because it gives you encapsulation/code reuse, which is a much more common need than i18n, and one that fits well depot at this stage of its development.
This page starts with an orphan “end”. Guess the book still needs to pass through a final revision of these details, but just in case :).
When following the following provided directions on my Snow Leopard iMac, my path is different than the typical value provided:
“All you need to do here is verify that each command is found in the same path, typically /opt/local/bin.”
On my system, the “for cmd in ruby irb gem rake; do which $cmd; done” command displays the following:
iMac:~ Matt$ for cmd in ruby irb gem rake; do which $cmd; done
/usr/bin/ruby
/usr/bin/irb
/usr/bin/gem
/usr/bin/rake
If my result is typical, maybe change the /opt/local/bin to the /usr/bin path.
The ERb snippet at the top of the page checks whether the cart is empty using line_items.count.zero?
Association collections provide line_items.empty? as a more specific way to check precisely that.
The migration name patterns “add_XXX_to_TABLE” and “remove_XXX_from_TABLE” do not match the example “rails generate migration add_quantity_to_line_item quantity:integer” because “line_item” is not a table name.
The example works because the migration generator pluralizes whatever it captures as TABLE, but anyway the patterns and the example differ in that detail.
May I suggest renaming the migration to “add_quantity_to_line_items”?
(page number is from iPad version)
first link_to example…
Time to say
<%= link_to “Goodbye!”, say_goodbye_path %>
should have ! outside of ERb to be consistent with prior example, as in
Time to say
<%= link_to “Goodbye”, say_goodbye_path %>!
(Totally minor! :-)
The URL at the top of the page that points to the documentation of fixtures in the Active Record API has an ar subdomain (I do not reproduce it here to avoid the spam filter).
Rails components had individual APIs in the past, but a few months ago we decided with David that they weren’t worth the trouble. The corresponding rake tasks have been removed, and the procedures that generate the Rails docs only generate API and guides nowadays. (Note the 2008 in the that page.)
May I suggested to point to the same file but in the Rails API?
Near the top of the page: “we will modify our controller to call paginate”. Since “paginate” is a method name guess you’d use fixed-width font there.
The :test delivery method for development is handy, but still pushes mails into AM::Base.deliveries, an array we normally do not care about in development mode. I normally set config.action_mailer.delivery_method to false, which does not even do that.
I think it is worth mentioning that in any case you can see the email in the log, should you check it is working fine, copy an activation URL, etc.
The arrow of “:name\t=> ”Dave Thomas“” both in 196, and 197 is not aligned with the rest of the arrows of the hash.
The second argument in the calls to assert_equal in the snippet in the middle of the page are aligned except one (order.email). Same on page 197.
ActiveRecord -> Active Record.
This page explains config.active_support.bare and says “In fact, one of the configuration options that Rails provides is to not include Active Support libraries at all”.
That’s not exactly that way, you get some AS included in your application.
The applications has whatever AS extensions are needed for the framework itself. Rails has been refactored to cherry-pick from AS strictly what’s needed (in theory, of course), but still that’s quite a lot.
Suggestion here would be to explain this, or to add perhaps a footnote about it.
The only reference to _add_price_to_line_item.rb is in eBook version B.12 at Page 387?
So up to this point a migration has not taken place which includes any ‘price’ or ‘total orders’ being displayed in the Admin area. If anyone knows how to fix this, I’d appreciate it! Thx
under the application_helper.rb code,
attributes[“style”] = “display: none”
shouldn’t that be
attributes[“style”] = “display: none;”
CSS needs a semicolon
I believe the code segment on this page has a technical error/typo. Shouldn’t “assert_redirected_to cart_path(assigns(:line_item).cart)” be “assert_redirected_to cart_path(assigns(:line_items).cart)?”
With :line_items being plural?
Hi, I have the second, the third, and the beta of the fourth edition. But I am somewhat disappointed about the latter one. As someone familiar with older versions of rails, I would have expected a chapter about what’s new and different in rails 3 from older rails versions (or older editions of the book). A need to read the whole book in order to - maybe - find the differences is too much of an overhead.
The index reference to Git for development leads to a page that has nothing to do with Git (107). The page after has some information. But the best info can be found on page 93. (A2 Playtime)
The sentence “In previous versions of Rails, the files in the lib directory were automatically included in the search.” seems to be incomplete. There’s no “search” going on in the context of that paragraph.
The application’s load path does not contain subdirectories of app/models. Also, the config directory is not included in $:.
“These objects” near the bottom, has too much whitespace in between. I’ve observed this in other places, particularly after the first word starting a section. Check for example “So far” in “Grouping Controllers into Modules”. “Newcomers to” in “Naming Conventions”, etc. there a quite a few of them.
It is my understanding that you have a document generation pipeline that outputs LaTeX. In my experience it is very strange that LaTeX produces such whitespace. First, if you manually type a series of spaces LaTeX collapses them. Second, the algorithms to layout paragraph rarely leave holes like that, you know they are really good at this.
So this ticket just raises a flag, in case there’s something in the LaTeX generator or somewhere else that introduces these spaces somehow.
If the LaTeX source looks fine, please disregard this ticket.
The first paragraph in this page says “Rails obtained this information by asking the underlying database the first time we tried to use the Order class.”
Just a comment here. AR lazy loads the metadata from the database, you could use a model class without triggering that.
It is a nuance, perhaps deserves a footnote, or perhaps it was decided not to mention it for the sake of simplicity, which would be fine.
ActiveRecord -> Active Record, in the second paragraph.
Fully-qualified constant name for RecordNotFound?
“Order.where(”name = :name and pay_type = :pay_type“, {:pay_type => pay_type, :name => name})” has explicit curlies.
You know that’s not very idiomatic, and “Order.where(:name => params[:name], :pay_type => params[:pay_type])” in the same page has none.
There are more curlies like that in the book. If they are deliberate that’s fine, opening a ticket just in case.
There’s a find_by_sql call that concatenates three strings. That’s not very common in Ruby, you know, we normally use a multiline %{} or a heredoc.
Also seen on page 297.
ActionPack -> Action Pack in “Each of these activities was orchestrated by modules in the ActionPack component.”
In “If none of these things happens, an Unknown Action error is generated.” the words “Unknown Action” are in fixed width font.
I think that needs either lowercase and regular font, or else “AbstractController::ActionNotFound” in fixed-width font.
If you are quoting the error message in the rendered page, that’d be “Unknown action” with lowercase “a” and regular font.
The accepts request attribute is an array with Mime::Type objects that represent the MIME types in the Accept header.
The format attribute is unrelated to the Content-Type header. It may be defined by a virtual extension, eg /posts.xml, or by the Accept header (tricky, see implementation), with Mime::HTML as fallback.
The request object does not respond to the following methods: mime_type, path_without_extension, path_without_extension, path_without_format, path_without_format_and_extension, relative_path.
render :file no longer accepts a :use_full_path option.
minor typo…
“Now when we view our cart and click the Empty Cart button”
should be “Now when we view our cart and click the Empty cart button”
In the last paragraph of the page: “You know you how to add that field to the view.”
“You use the text and text_area helpers (on lines 4 and 9, respectively) to gather single-line and multiline input fields.”
Should be “text_field and text_area helpers”
The last command on page 29 is “sudo gem install sqlite3-ruby”; this command notifies the user that the gem has been renamed to just “sqlite3”. You might want to update the doc to reflect this. The full message given by the gem install command is:
Hello! The sqlite3-ruby gem has changed it’s name to just sqlite3. Rather than
installing `sqlite3-ruby`, you should install `sqlite3`. Please update your
dependencies accordingly.
There several things to revise regarding session stores:
This option also accepts a custom session store (don’t know whether that’s in the scope of the book though).
There’s a list item that reads: “The current controller object is accessible using the attribute named controller. This allows the template to call any public method in the controller (including the methods in ActionController).”
At the end it should say “ActionController::Base”.
Footnote 3 links to the edge guides. Those document the master branch, if possible it would be better to link to the stable guides.
The flow in Figure 21.2 starts with the “edit” action. Steps 2, 4, and 5 are consistent with it (except for a missing “_method” parameter in 4), but step 3 shows a form for creation.
The first complete paragraph says: “If the path given to an asset tag method includes a forward slash, then the path is assumed to be absolute, and no prefix is applied.”
In order to consider the path to be absolute, it has to start with a forward slash. Mere inclusion is not enough.
The first ERb snippet has this render call:
render(“shared/header”, :title => @article.title)
I think this idiom has not been introduced. That is, the idiom that does not use an explicit :partial option and passes locals in an ordinary hash.
This line of code
“expire_page\t:action => ”public_content“”
has a lot of whitespace between the macro and the symbol for no apparent reason.
The second paragraph has “ActiveRecord” in fixed-width font. Should be “Active Record” with a space and regular font.
Isn’t it a bit strange that created_at is used for :last_modified?
It is rare that an application does not allow the author to edit an article after publication. Guess updated_at would be a more realistic timestamp to base expiration on.
Footnote 1 links to the Rails wiki, but the wiki went down a while back and there’s no plan to resurrect it. Nobody noticed, it was not maintained and completely out of the radar of core. We decided with David that its time had arrived :).
jQuery has a lowercase “j”, but there are several occurrences of “JQuery”. A global search and replace here.
In “and to remove the now unnecessary prototype libraries”, capital “P” for Prototype.
“devise” should be in fixed-width font to be consistent with other plugin names.
“ActiveRecord” -> “Active Record” in “For example, datamapper replaces ActiveRecord”.
“We recommend you start by visiting the rubyonrails site” -> “We recommend you start by visiting the Ruby on Rails site”.
The “and”s in this enumeration are fine?
“There also are plenty of related categories that go beyond Ruby and Rails, such as Agile Practices, Testing, Design, and Cloud Computing, and Tools, Frameworks, Languages.”
Should be a comma after the second occurrence of “test” in the third paragraph. ie. “This test differs in the name of the test, in the …”
In the paragraph:
Now that we have the stylesheet all in place,
stylesheet should be stylesheets
I was confused with the relationship between belongs_to, and product_id / cart_id, as well as the use of .build on p126, so it may be worth explaining this more. Is it a rails naming convention that foreign_key fields end in _id ? Must they be defined in the table by the user, and as integers, rather than just by using belongs_to ? Does .build also assume the _id naming convention ? Also, to access e.g. the product_id, do I use e.g. line_item.product.id or line_item.product_id ?
“and not with all that much code” should probably read “and with not ….”
Here we change from using cart.line_items.build to cart.add_product to make use of new line_item quantity field. Could use of cart.line_items.build be disabled ? Or could it be overridden with a modified method, rather then using cart.add_product ?
With respect to the explanation of the “assigns” method:
“This method gives us access to the variables that have been (or can be) assigned by views.”
Perhaps I’m being overly pedantic, but the following wording seems clearer to me:
“This method gives us access to the instance variables that have been (or can be) assigned by controller actions for use in views.”
This is similar to how “assigns” is described at guides.rubyonrails.org/testing.html
Fourth line from top:
“instead, the id attributed should match…”
should probably be:
“instead, the id attribute should match…”
(Roughly the middle of the page)
“Products have many line_items and line_items belong to a order.”
should be:
“Products have many line_items and line_items belong to an order.”
In the last line test file name is given as notifier.rb it should have been notifier_test.rb
in css, for #main you show padding-top: 4ex;, I believe you mean 4em;
“In Rails, a model is automatically mapped to a database tablewhose name is the plural form of the model’s class.”
A space is missing between ‘table’ and ‘whose’
<%= hidden_div_if(…) do %>
should be:
<% hidden_div_if(…) do %> [at least for Rails 3.0.5]
Adding the ‘=’ generates syntax error as the ‘do’ is enclosed in a .to_s call
For installing will_paginate, i’ve run “bundle install”. Then go to browser and reflash page of localhost:3000/orders ,nothing but an error shows that Order.paginate can not be invoked.
so i restart rails server,and it comes ok now.
do you think it’s better to remind readers for this ?
Figure 15.8 should show translated attributes according to the text (Page 230, last paragraph: “We are pleased to see the model and attribute names translated in Figure 15.8,
on the following page”). They don’t.
What about creating user unit tests too.
In the sentence:
“Armed with all this background about flash data, we can now change our show method to intercept
bad product ids and report on the problem:”
‘product ids’ should be ‘cart ids’
Some pages still work when no user is logged in - this is no longer tested as for all tests, a user is pre-logged in. Might be better to add “login_as :one” in specific tests.
Also, tests missing for redirection back to login when no-one is logged in.
… mapped to a database tablewhose name is the …
should have a space between table and whose
… mapped to a database table whose name is the …
Problem with store_controller_test.rb, the test fails if you use the code as outline in the book however if you change the following line:
assert_select ‘#main .entry’, 3
to
assert_select ‘#main > .entry’, 3
then it works as expected and the test passes.
This suggests that this is not the final version:
“This beta book was written using Rails version 3 (specifi- cally Rails 3.0.5 at the current time).”
Running the load_orders.rb script with rails runner does not seem to populate the Orders table. What would be really useful in the book is to actually mention how to debug each step in case something goes wrong. The command simply executes with no indication of what happened. At this stage, no logging or printing to the console is discussed.
Kindle location 411 (don’t know if that’s searchable)
on creating a local version of rails docs, the book missed the step “bundle install”
rails_apps> cd dummy_app
dummy_app> bundle install
dummy_app> rake doc:rails
Under Generating the Scaffold, second paragraph: the word “tablewhose” is one word.
On page 100 there is a page break which seem out of place. The phrase looks like this :
“Instead, as we’ll
see shortly, the name gives us a convenient way to reference test data inside our test code.”
This leaves half of page 100 empty for no apparent reason.
task_f fails functional tests out of the box.
Downloaded code
rake db:migrate
rake test:functionals
(in /home/dnehme/sandbox/agilerailsbook/from_authors/code/depot_f)
Loaded suite /home/dnehme/.rvm/gems/ruby-1.9.2-p180/gems/rake-0.8.7/lib/rake/rake_test_loader
Started
…….E…………..
Finished in 0.503925 seconds.
1) Error:
test_should_create_line_item(LineItemsControllerTest):
ActiveRecord::RecordNotFound: Couldn’t find Product without an ID
CSS for id main has a bad unit type:
#main {
…
padding-top: 4ex;
…
}
since all the other unit type in that piece of css are em’s I believe it should be
#main {
…
padding-top: 4em;
…
}
hitting the “add to cart” causes an error “NoMethodError in LineItemsController#create” undefined method `save’
this is because the cart.add_product function is returning current_item.quantity not current_item
easy to fix by add a line after current_item.quantity += 1 :
current_item
Paragraph 6, beginning, “You can create and initialize…” the end of that line is “aset”, should be “a set”
You could better explain the reason your assert_equal uses the statement “product.errors[:price].join(‘; ’)” The text says you “use the handy join method to concatenate each message” and “express the assertion based on the assumption there is only one such message.”
Then why not just use product.errors[:price][0]? It better illustrates what your text explains. The join seems somewhat convoluted.
In the sentence “The combination of form_for and the various field-level helpers (such as text_field) give it this information.”, in my opinion, ‘give’ should be ‘gives’ as it is ‘the combination’ that gives the information, i.e. 3rd person singular.
Active Record Callbacks have been changed (figure 19.2 and page text is outdated). Instance method “overwrites” for callbacks are deprecated in favor of class method handlers. Both instance methods and class handlers for before_validation_on_create/_on_save and after_validation_on_create/_on_save have been removed in favor of new class handler before_validation(:on => :create) patterns. There also new callbacks for handling transaction commits and rollbacks.
Figure 15.7 should be switched with Figure 15.8 according to their legends.
The location is listed as demo1, it should be demo — see following:
…the current file is shown as, at the bottom of page:
work/demo1/app/controllers/say_controller.rb
…it should be:
work/demo/app/controllers/say_controller.rb
I believe OrdersController::create() needs to set cart in the else (failure) case on the
order.save. If order.save fails due to validation errors, render :action => "new" is executed. But our application layout expects
cart to be set in the hidden_div_if() call.
I recommend the following addition in order_controller.rb, create() method:
if order.save
...
else
>
cart = current_cart
…
end
Alas, Deploying Rails Applications (ZT08) is out of print - see elsewhere on pragprog.com - and the version of chapter 6 available online seems to have no great relevance to deployment on Windows. (new edition on the way?)
re #46865 : Works for me per the text. Has Joel got a space between “#main” and “.entry”?
re #46977 : Works for me per the text. Has Ian omitted the “current_item” immediately before the function “end” ?
Isn’t it good idea to include discussions on ‘authenticity_token’ and ajax request, protect_from_forgery?
In the first sentence in the “A Place for Supporting Libraries” section on page 255 there should be a space between “Thelib” that is it should be: “The lib”…
On page 257, in the section entitled: “A Place for Static Web Pages”, there should be a space in “Thepublic”, that is, it should be “The public”…
This might be a good place to explain why “Product” products, but "Store" store. And also: why your command “rails generate controller store index” has lowercase “store” but your previous command “rails generate scaffold Product…” has uppercase “Product”. (Or, whether it matters.) It’s confusing.
The inconsistent use of bold text in your HTML tags on this page (and elsewhere) is somewhat confusing. Is this the new text to be typed by the reader? No, it’s not (in this case). I suggest using consistent text formatting for HTML tags and wherever you indicate text changes need to be made.
After following the code on page 122, the CSS was not applying correctly to the main cart view. I changed the “#store” id to “#main” for the newly added CSS, and this applied the CSS.
In the first paragraph of 15.2 there is a space between I18n.translate and the closing sentence period.
rails_apps> rails new dummy_app
rails_apps> cd dummy_app
dummy_app> rake doc:rails
This step fails for me on OS X 10.6 with built-in Ruby 1.8.7, RubyGems 1.8.4, rake 0.9.0, Rails 3.0.7.
Trace output below:
rake aborted!
undefined method `task’ for #
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:215:in `initialize_tasks’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:139:in `load_tasks’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `send’
/Library/Ruby/Gems/1.8/gems/railties-3.0.7/lib/rails/application.rb:77:in `method_missing’
/Users/justin/dummy_app/Rakefile:7
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/rake_module.rb:25:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:495:in `raw_load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:78:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:77:in `load_rakefile’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:61:in `run’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:129:in `standard_exception_handling’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/lib/rake/application.rb:59:in `run’
/Library/Ruby/Gems/1.8/gems/rake-0.9.0/bin/rake:31
/usr/bin/rake:19:in `load’
/usr/bin/rake:19
In the code continued from page 226 from file (depot_s/app/views/orders/_form.html.erb) t(‘.pay_type’) seems to be missing for the payment type label. This also seems to be missing from the downloadable example code.
For the es configuration file on page 227 (depot_s/config/locales/es.yml) for pay_type it says “Pagar con” while in the screenshot on page 228 it depicts Forma de page.
After completing the code additions depicted on page 229 the error displayed do not match figure 15.7. Rails complains that “translation missing: es.activerecord.models.order” This error occurs even after using the downloadable code in depot_t.
Would it not be better to check for the fragment with fragment_exist?() instead of read_fragment() to determine if the database trip is necessary? The call to read_fragment() actually reads it in, while fragment_exist?() does not and accomplishes what is desired.
The ActiveResource example does not work with the authentication added to the depot application developed in the book. I modified the authorize() method in the application controller to handle basic authentication as well by applying that when the Mime::XML type was requested. I don’t recall if this was something optionally added through the exercises (I went through this fairly quickly just to catch new Rails 3 stuff), but it was confusing at this point. I use the standard authentication otherwise for non-XML requests. I suggest adding something here to make basic authentication work because the ActiveResource section is very important IMO.
‘#cart, #cart table’ should be ‘#side, #cart table’ in depot.css
“Thevendor” -> “The vendor”, first paragraph of “A Place for Third-Party Code” section.
“Theconfig” -> “The config”, first paragraph of “A Place for Configuration” section.
“What you put into these configuration file” -> “files”, first paragraph.
I’m using Rails 3.0.7. It seems that the labels for :name, :email and :pay_type do not pick up their localized values automatically until the model itself is localized on page 230. The picture on page 228, therefore, doesn’t look like shown in (my?) reality.
On the bottom it says that “it sets the locale in the session from the params”, but actually there is no assignment to ‘session’ in the code.
Furthermore, the whole sentence is not really understandable - what does “it leaves the locale alone” mean?
The logging facility explanation introduce a security vulnerability:
it is suggested to log the cart name (#{params[:id]}) directly into the log file. This input (as every user input) need to be sanitized otherwise you end-up with a log injection attack.
Because this book is mainly for beginner, emphasizing that user input should not be trusted is very important so they get good habits.
The link to the download references depot_c instead of depot_b. The depot_b test file matches the changes shown in the book.
Just below the middle of the page the gray box for displaying the file name is missing for:
test/unit/product_test.rb
The gray box should be above the code snippet that adds
fixtures :products
Thanks…
The shaded text boxes containing the file names are very helpful.
Would it be possible increase the font size of the file names in the next edition so that the file names are easier to read?
Thanks.
The last paragraph at the bottom of the page says to add a different product to the cart, but the illustration shows the cart with duplicate items:
- Programming Ruby 1.9
- Programming Ruby 1.9
Might be nice to mention in the last paragraph that in order for multiple items to be displayed in the cart the browser must be configured to accept cookies (at least from localhost for those who have their browsers set to not accept cookies by default).
Thanks.
At the top of the page, the shaded box with the file name is missing for app/models/cart.rb
For show.html.erb code, at first it wasn’t clear whether or not the code listing is replacing all of what was already in show.html.erb.
There are several other instances in the book where this isn’t clear (too vague, I know). I’ll try to note other instances when I see them.
In this case it might be nice to explicitly say something like:
To prevent the message box from displaying, delete
<%= notice %>
At the end of the paragraph above the code listing for depot.css it would be nice to mention that this is a new code block to be added to the /* Global styles */ section.
(In other words, it doesn’t replace or modify any code that’s already there.)
Thanks.
The first sentence of the first paragraph under section 11.3 Iteration F3: Highlighting Changes reads “Included with Rails is a number of Javascript libraries.” This should read “Included with Rails are a number of Javascript libraries.” Or, perhaps, “A number of Javascript libraries are included with Rails.”
When I try to save an order which is not filled, the “Pay type” appears twice instead of one.
one is text_field and another is select.
The current version of line_items create does not work.
The total method needs to have a value returned from it. Something as simple as “sum” would do.
I am providing a sample below.
def total_wrong
sum = 0
line_items = [10,20,30,40]
line_items.each {|li| sum += li}
end
def total_correct
sum = 0
line_items = [10,20,30,40]
line_items.each {|li| sum += li}
sum
end
puts “Wrong: #{total_wrong}”
puts “Correct: #{total_correct}”
The rake test failures that updating products_controller_test.rb should fix don’t get fixed with the depot_c file that is provided.
TEXT FROM BOOK:
“(Note that this code uses %{…}. This is an alternative syntax for double-quoted string literals, convenient for use with long strings. Note also that because it uses Rails’ create method, it will fail silently if records cannot be inserted because of validation errors.)”
I have some seed data that used to work in an earlier version of rails, but not in rails 3.1.
turns out i needed to add the “magic comment”. This line at the top of my file was both necessary and sufficient for my seeds.rb to be processed correctly:
to the very very top of the script.
this should be mentioned here so that you can accept special characters such as the registered trademark symbol, etc., in seed data while still being able to use the convenient %{…} syntax mentioned as advantageous for use with long strings.
it should probably just be with the default file anyway since rails3 supports utf-8 and may even assume it is there?
On the first line the coma is misplaced (I guess).
“The return statement is important here; without, it you will…”
Should be:
“The return statement is important here; without it, you will…”
BTW: My book version isn’t listed. It reads:
P1.0 printing, March 2011
Version: 2011-3-11
After title “13.1 Iteration H1: Sending Confirmation Emails” on page 169 the first word is “Thereare”, but should be “There are”
Should the end of the second paragraph say “helpers that come with Rails”?
“…it therefore it is possible to avoid…” -> “…it therefore is possible to avoid…”
The ‘private/end’ section in the code example (product.rb) does not appear in the downloadable code and causes an error.
skip_before_filter is deprecated in Rails 3 - this is a version 2.x function
Screen-shot shows for pay_type: “Forma de pago” but on page 216 you wrote “Pagar con”. Furthermore the form field “name” and “pay_type” aren’t translated in this stage.
Kept receiving error “You have a nil object when you didn’t expect it!” from the line:
line_item =
cart.add_product(product.id)
Changed the line to
line_item =
cart.add_product(:product_id)
and everything works.
Near bottom of page 424: “You know you how to add that field…”
Snow Leopard users wishing to install Ruby 1.9.2 instead of using the stock 1.8.7 version with Rails should do the following:
sudo port install ruby19 +nosuffix # Installs Ruby 1.9.2 without the “1.9” suffix into /opt/local/bin
(“sudo port install rb-rubygems” is now unnecessary, as gem is installed with Ruby 1.9.2 by default.)
The rest (from gem update —system onward) is still applicable. I did find that, even though “which ruby irb gem rake” showed them all in /opt/local/bin, I had to “sudo gem install rake” (p. 27) to update the rake version to make “rails server” happy (on p. 36).
First sentence: “…reflect DHH’s philosophy…”. What does that mean? Please enlighten me! Google not helpful…
Im not really sure with the version of book.. well i dont really know hot to create that depot.css.. I cannot find it after i finished depot_b/db/seeds.rb.. Just wanna ask if it depot.css will be downloaded from the net?
mapped to a database tablewhose….
—-> No space between “table” and “whose”
The distance_of_time_in_words helper (first formatting helper example) is called with Time.now and Time.local(2010, 12, 25) as arguments. Same arguments are used in time_ago_in_words (the fourth example) is called with Time.local(2010,12,25), and it calls internally distance_of_time_in_words adding a Time.now as second parameter. However, the first output is supposed to be 5 months while the fourth is 3 month. I suggest that it should be the same because this can lead to a misconception.
Second-last paragraph: ‘aset of elements’ should be ‘a set of elements’
Going from 3.0 to 3.1 in Agile Web Development with Rails 3.1
In your gemfile:
gem ‘sprockets’, ‘2.0.0.beta10’ # this is a Rail 3.1.0.rc4 dependency
This allows the CSS to load without problems. I tracked this down after a couple hours; it doesn’t look very common. It may be fixed in future versions but as of 8/14/2011 it needs to be fixed manually.
In the seeds code
Change ‘/images/image_name.jpg’ to ‘/assets/image_name.jpg’ because of the assets pipeline in Rails 3.1.
(dated: 8/14/2011)
While we are here, we should attend to two other things.
But only the first one mentioned in the book.
The code snippets for the
when the ‘select * from line_items’ is run after placing an order, the output from sqlite returns a row with a column ‘price = 49.5’. The price column isn’t part of the initial create or added subsequently - maybe I’ve missed it, but I can’t find it anywhere?
Please ignore my previous comment about price, it’s added as part of the playtime exercise (as stated in the following paragraph - doh!)
The Ajax magic section found on pages 145 to 146 creates the appropriate display in all tested browsers except IE 9. Tested browsers include: Opera 11.50, Firefox 3.6.13, and Chrome 13.0.782.215. The problem with the functionality in IE 9 is that the cart item is added twice to the cart itself: everytime an item’s add button is pushed, it adds the item to the cart twice (maybe something to do with the DOM event handler?) Don’t know if this is a known bug with IE and/or Rails or not.
So it seems that you didn’t update any of your code downloads to include rails 3.1 applications……no asset directory in any of the code…..therefore….no images available where your pdf links take us, nor in the code downloads…..probably no scss files also….
Seeds.rb still has /images/image.jpg in all urls…..need to delete the leading /image directory……
Code sample for product.rb is missing reference ot fresh_when
Chapter 6. Task A: Creating the Application" of the PDF version
He shows the contents of <application.html.erb>. And, he is trying to indicated that the file should be edited and the following code should be added,
Generally, when this is the case there is a “bullet” prefixed on the line that needs to be changed/added. But here i don’t see that and it looks as though that piece of code is already part of that file.
link for ….code/depot_b/app/assets/images should actually be:
….code/rails31/depot_b/app/assets/images/
The code zip for Rails31 doesn’t have all of the images for the seed file. Also hashes are specfied as :key ==> value versus key: value.
Small typo
The first line references:
“app/controllers/line_items_con-troller.rb”
instead of:
“app/controllers/line_items_controller.rb”
I’m reading on Kindle - location 1687 code for rails31/depot_b/app/views/products/index.html.erb
The
2011-09-05 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
72 | TYPO | and connection these rules to the to the page by defining an HTML class | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | ERROR | The link for the seeds.rb file works, but it seams to be the wrong one. | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
66 | 66 | OK | In the migration, Shouldn’t it be: | 2011-09-03 | See "Choosing a Ruby version" on the top of PDF page 4. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
300 | ERROR | In Figure 47 (Sequence of Active Record callbacks) the operations“update operation” and “insert operation” are interchanged. | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
152 | TYPO | In the last paragraph: | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | ERROR | Link at bottom of page is wrong | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
176 | TYPO | The code for “script/load_order.rb” is neither provided nor linked to . | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
177 | SUGGEST | The <%= will_paginate to #… | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
71 | TYPO | Seeds.rb file: The apostrophe in “Javasript’s”, line 14 is giving an error. invalid multibyte char (US-ASCII) | 2011-09-03 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
251 | TYPO | “InChapter 3” needs a space | 2011-09-05 | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
95 | 75 | OK | rails31/depot_b/app/views/products/index.html.erb
|