I''m new to Ruby on Rails and came across a problem I could not solve alone. I''ve a pretty simple RJS file that looks like the following: 3.times do page.insert_html :bottom, ''messages'', ''test'' end page.call ''updateMessageWindow'' However this snippet gives a syntax error: ActionView::TemplateError (compile error D:/Eigene Dateien/Programming/Web/AjaxChat/app/views/chat/update.js.rjs:1: syntax error, unexpected tIDENTIFIER, expecting kEND 3.times do page.insert_html :bottom, ''messages'', ''test'' end page.call ''updateMessageWindow'' ^) on line #1 of chat/update.js.rjs: 1: 3.times do page.insert_html :bottom, ''messages'', ''test'' end page.call ''updateMessageWindow'' What is wrong with it? If I remove the last line (page.call ''updateMessageWindow'') everything works as expected. -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Mon, Sep 22, 2008 at 9:44 AM, Jim Gecko <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> > I''m new to Ruby on Rails and came across a problem I could not solve > alone. > I''ve a pretty simple RJS file that looks like the following: > > 3.times do > page.insert_html :bottom, ''messages'', ''test'' > end > page.call ''updateMessageWindow''Hi, you forgot the block local variable. Thus, the above should have been developed as follows: 3.times do |page| page.insert_html :bottom, ''messages'', ''test'' end page.call ''updateMessageWindow'' Good luck, -Conrad --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Sep 22, 7:31 pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > 3.times do > > page.insert_html :bottom, ''messages'', ''test'' > > end > > page.call ''updateMessageWindow'' > > Hi, you forgot the block local variable. Thus, the above should have been > developed > as follows: > > 3.times do |page| > page.insert_html :bottom, ''messages'', ''test'' > end > page.call ''updateMessageWindow'' >That''s not true. You don''t need the block variable (and in your example it''s doubly bad because you would be overwriting the magic page variables with the integers 0 to 2. What''s the whole of the rjs file ? Fred --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---
Frederick Cheung wrote:> On Sep 22, 7:31�pm, "Conrad Taylor" <conra...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> �page.insert_html :bottom, ''messages'', ''test'' >> end >> page.call ''updateMessageWindow'' >> > That''s not true. You don''t need the block variable (and in your > example it''s doubly bad because you would be overwriting the magic > page variables with the integers 0 to 2. > > What''s the whole of the rjs file ? > > FredRight, as it''s an rjs file it is automatically wrapped inside a block. After struggling a day with the code and not being able to detect any syntax error whatsoever I checked the encoding of the line endings. To my surprise they were encoded as carriage returns (CR, Mac style). Changing them to Linux (LF) or Windows (CR+LF) style solved the problem and the parser was happy again. I have no clue why my editor (intype) suddenly inserted CRs instead of line feeds (other files I''ve written with the same editor have a correct encoding of the line endings). To conclude, the syntax error hadn''t anything to do with RJS templates in special. -- 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-/JYPxA39Uh5TLH3MbocFFw@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 -~----------~----~----~----~------~----~------~--~---