This is kind of frustrating (but no doubt helpful in the long run) that after following along and coding , and d/l the code the same error is appearing. For those who are familiar with the depot app, I''ve run into a problem after fixing the cart to reflect quanitites. I worked through the intended error messages but now have this appearing: SyntaxError in StoreController#add_to_cart app/models/cart.rb:15: parse error, unexpected $, expecting kEND Not sure where to turn to figure this out being a newb. TIA Stuart -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/93f630d7/attachment.html
Dark Ambient wrote:> This is kind of frustrating (but no doubt helpful in the long run) > that after following along and coding , and d/l the code the same > error is appearing. > For those who are familiar with the depot app, I''ve run into a problem > after fixing the cart to reflect quanitites. I worked through the > intended error messages but now have this appearing: > > > SyntaxError in StoreController#add_to_cart > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > Not sure where to turn to figure this out being a newb. > > TIA > Stuart >Can you post a few lines before and after Line 15 from app/models/cart.rb It may help the rest of us see what may be wrong.. Cheers Mohit
Here is the entire file: class Cart include Reloadable attr_reader :items def initialize @items = [] end def add_product(product) existing_product = @items.find {|item| item.product == product} if existing_product existing_product.increment_quantity else @items << CartItem.new(product) end end Stuart On 6/8/06, Mohit Sindhwani <mo_mail@onghu.com> wrote:> > Dark Ambient wrote: > > This is kind of frustrating (but no doubt helpful in the long run) > > that after following along and coding , and d/l the code the same > > error is appearing. > > For those who are familiar with the depot app, I''ve run into a problem > > after fixing the cart to reflect quanitites. I worked through the > > intended error messages but now have this appearing: > > > > > > SyntaxError in StoreController#add_to_cart > > > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > > > Not sure where to turn to figure this out being a newb. > > > > TIA > > Stuart > > > > Can you post a few lines before and after Line 15 from > app/models/cart.rb It may help the rest of us see what may be wrong.. > Cheers > Mohit > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/284651bd/attachment-0001.html
On 6/8/06, Dark Ambient <sambient@gmail.com> wrote:> > This is kind of frustrating (but no doubt helpful in the long run) that > after following along and coding , and d/l the code the same error is > appearing. > For those who are familiar with the depot app, I''ve run into a problem > after fixing the cart to reflect quanitites. I worked through the intended > error messages but now have this appearing: > > SyntaxError in StoreController#add_to_cart > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > >might you have forgotten an end (closing the begin/rescue/else work) statement? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/a46546a9/attachment.html
guess not =) On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com> wrote:> > On 6/8/06, Dark Ambient <sambient@gmail.com> wrote: > > > This is kind of frustrating (but no doubt helpful in the long run) that > > after following along and coding , and d/l the code the same error is > > appearing. > > For those who are familiar with the depot app, I''ve run into a problem > > after fixing the cart to reflect quanitites. I worked through the intended > > error messages but now have this appearing: > > > > SyntaxError in StoreController#add_to_cart > > > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > > > > might you have forgotten an end (closing the begin/rescue/else work) > statement? >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/5b5f465a/attachment.html
On 6/8/06, Dark Ambient <sambient@gmail.com> wrote:> > Here is the entire file: > > class Cart > include Reloadable > attr_reader :items > def initialize > @items = [] > end > > def add_product(product) > existing_product = @items.find {|item| item.product == product} > if existing_product > existing_product.increment_quantity > else > @items << CartItem.new(product) > end > end >aren''t you missing an end statement to close the Cart class? -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/b86a27a0/attachment.html
Just figured it out. I was missing an end at the end of the file. Stuart On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com> wrote:> > > guess not =) > > > On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com > wrote: > > > > On 6/8/06, Dark Ambient <sambient@gmail.com> wrote: > > > > > This is kind of frustrating (but no doubt helpful in the long run) > > > that after following along and coding , and d/l the code the same error is > > > appearing. > > > For those who are familiar with the depot app, I''ve run into a problem > > > after fixing the cart to reflect quanitites. I worked through the intended > > > error messages but now have this appearing: > > > > > > SyntaxError in StoreController#add_to_cart > > > > > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > > > > > > > might you have forgotten an end (closing the begin/rescue/else work) > > statement? > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/9023beb1/attachment-0001.html
So much for RadRails and it''s syntax checking :) Stuart On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com> wrote:> > > guess not =) > > > On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com > wrote: > > > > On 6/8/06, Dark Ambient <sambient@gmail.com> wrote: > > > > > This is kind of frustrating (but no doubt helpful in the long run) > > > that after following along and coding , and d/l the code the same error is > > > appearing. > > > For those who are familiar with the depot app, I''ve run into a problem > > > after fixing the cart to reflect quanitites. I worked through the intended > > > error messages but now have this appearing: > > > > > > SyntaxError in StoreController#add_to_cart > > > > > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > > > > > > > might you have forgotten an end (closing the begin/rescue/else work) > > statement? > > > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/5abbc8cb/attachment.html
Dark Ambient wrote:> So much for RadRails and it''s syntax checking :) > > Stuart > > On 6/8/06, *jeanpierre@gmail.com <mailto:jeanpierre@gmail.com>* < > jeanpierre@gmail.com <mailto:jeanpierre@gmail.com>> wrote: > > > guess not =) > > > On 6/8/06, *jeanpierre@gmail.com <mailto:jeanpierre@gmail.com>* < > jeanpierre@gmail.com <mailto:jeanpierre@gmail.com>> wrote: > > On 6/8/06, *Dark Ambient * <sambient@gmail.com > <mailto:sambient@gmail.com>> wrote: > > This is kind of frustrating (but no doubt helpful in the > long run) that after following along and coding , and d/l > the code the same error is appearing. > For those who are familiar with the depot app, I''ve run > into a problem after fixing the cart to reflect > quanitites. I worked through the intended error messages > but now have this appearing: > > > SyntaxError in StoreController#add_to_cart > > app/models/cart.rb:15: parse error, unexpected $, expecting kEND > > > might you have forgotten an end (closing the begin/rescue/else > work) statement? > > > >It''s just keeeping you alert!! :P Cheers, Mohit.
I was missing it , see my last post to see I found it. Thanks Stuart On 6/8/06, jeanpierre@gmail.com <jeanpierre@gmail.com> wrote:> > On 6/8/06, Dark Ambient <sambient@gmail.com> wrote: > > > > Here is the entire file: > > > > class Cart > > include Reloadable > > attr_reader :items > > def initialize > > @items = [] > > end > > > > def add_product(product) > > existing_product = @items.find {|item| item.product == product} > > if existing_product > > existing_product.increment_quantity > > else > > @items << CartItem.new(product) > > end > > end > > > > > aren''t you missing an end statement to close the Cart class? > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails > > >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/d1192ebc/attachment.html
On 6/8/06, Dark Ambient <sambient@gmail.com> wrote:> I was missing it , see my last post to see I found it.Kindly recall that there are posting delays. :) He may have been trying to be helpful and didn''t see the posting that you had found it on your own because it hadn''t come through yet. No need to be snippy. (Text does not carry tone very well, so if you weren''t intending to be snippy, my apologies.) -Curtis
My apologies, it wasn''t my intention to be snippy and didn''t mean it like that. Thanks for pointing out that about delays though as it hadn''t crossed my mind. I just wanted to make sure it was understood that the problem was solved and appreciate everyone''s input. Stuart On 6/8/06, Curtis <cuspendlove@gmail.com> wrote:> > On 6/8/06, Dark Ambient <sambient@gmail.com> wrote: > > I was missing it , see my last post to see I found it. > > Kindly recall that there are posting delays. :) He may have been > trying to be helpful and didn''t see the posting that you had found it > on your own because it hadn''t come through yet. No need to be snippy. > (Text does not carry tone very well, so if you weren''t intending to > be snippy, my apologies.) > > -Curtis > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060608/654578b6/attachment.html
I had this same problem and I find this really weird because I was using the actual code supplied by the book and was getting the error. When I added an extra "end" to the bottom of the file it worked. Can someone tell me why this code works: 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 It seems to me that there is one too many "end"s here. Is that right? I am also a newb. Thanksz! -- Posted via http://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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
> 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 > > It seems to me that there is one too many "end"s here. >Looks okay to me. The first "end" closes the "if-else" block The second "end" closes the "def" method The third "end" closes the "class" declaration -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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 via http://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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 17 May 2010 02:50, Orient Fang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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 >... > **** 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 > --Are you absolutely certain that is the right cart.rb? Is that the complete file? It looks ok to me. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
clanlaw wrote:> On 17 May 2010 02:50, Orient Fang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >> **** cart.rb file as following, >> � � � �else >> � � � �@items << CartItem.new(product) >> � � � �end >> � �end >> end >> -- > > Are you absolutely certain that is the right cart.rb? Is that the > complete file? It looks ok to me. > > ColinHi Colin, it is, I am sure. I''m wondering is there anywhere else cause the problem. thanks for response! -- Posted via http://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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
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...-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org > To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
On 18 May 2010 05:04, Orient Fang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote:> clanlaw wrote: >> On 17 May 2010 02:50, Orient Fang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> **** cart.rb file as following, >>> � � � �else >>> � � � �@items << CartItem.new(product) >>> � � � �end >>> � �end >>> end >>> -- >> >> Are you absolutely certain that is the right cart.rb? Is that the >> complete file? It looks ok to me. >> >> Colin > > Hi Colin, > it is, I am sure. I''m wondering is there anywhere else cause the > problem.There is something odd going on. I suggest you comment out the contents of the file and add bits back in till it fails. Maybe you have an unprintable character that is causing the problem. Colin -- 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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Colin Law wrote:> On 18 May 2010 05:04, Orient Fang <lists-fsXkhYbjdPsEEoCn2XhGlw@public.gmane.org> wrote: >>> Are you absolutely certain that is the right cart.rb? Is that the >>> complete file? It looks ok to me. >>> >>> Colin >> >> Hi Colin, >> it is, I am sure. I''m wondering is there anywhere else cause the >> problem. > > There is something odd going on. I suggest you comment out the > contents of the file and add bits back in till it fails. Maybe you > have an unprintable character that is causing the problem. > > Colinhi Colin I solved the problem, it''s because I use the utf8 encoding for the new *.rb file. the default is the ANSI encoding. Thanks for you response -- Posted via http://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-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.