I copied and pasted and ran this code and it worked fine for me. Any stray "," characters?
On May 16, 6:50 pm, Orient Fang <li...@ruby-forum.com> wrote: > HI, > I have almost the same issue when I follow the 3rd Edtion. > but I verified the every type characters, there should be no mistakes. > Any one could help? > --------- > SyntaxError in StoreController#add_to_cart > D:/InstantRails/rails_apps/lzpback/app/models/cart.rb:14: syntax error, > unexpected kEND, expecting $end > RAILS_ROOT: D:/InstantRails/rails_apps/lzpback > Application Trace | Framework Trace | Full Trace > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in > `load_without_new_constant_marking' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:380:in > `load_file' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:521:in > `new_constants_in' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:379:in > `load_file' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:259:in > `require_or_load' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:425:in > `load_missing_constant' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:80:in > `const_missing' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:92:in > `const_missing' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:437:in > `load_missing_constant' > D:/InstantRails/ruby/lib/ruby/gems/1.8/gems/activesupport-2.3.5/lib/active_support/dependencies.rb:96:in > `const_missing' > D:/InstantRails/rails_apps/lzpback/app/controllers/store_controller.rb:19:in > `find_cart' > D:/InstantRails/rails_apps/lzpback/app/controllers/store_controller.rb:9:in > `add_to_cart' > Request > Parameters: > {"authenticity_token"=>"jp209H0whp2bnxAl+JiDhLx4clqJbMwei4Oz9eUyBwo=", > "id"=>"2"} > Show session dump > Response > Headers: > {"Content-Type"=>"", > "Cache-Control"=>"no-cache"} > **** cart.rb file as following, > -------- > class Cart > attr_reader :items > def initialize > @items = [] > end > def add_product(product) > current_item = @items.find {|item| item.product == product} > if current_item > current_item.increment_quantity > else > @items << CartItem.new(product) > end > end > end > -- > Posted viahttp://www.ruby-forum.com/. > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to rubyonrails-t...@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/rubyonrails-talk?hl=en. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-t...@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.