got this error [rails 2.3.2, Ruby 1.8.7]
syntax error, unexpected tIDENTIFIER, expecting kEND
... if n.send(order_attribute) > self.send(order_attribute)
idoesn''t like the ''>'' ... what''s wrong ?
here is my action...
def move_to_ordered_child_of(parent, order_attribute,
ascending=true)
if parent
left = nil
parent.children.each do |n|
if ascending
left = n if n.send(order_attribute) < self.send
(order_attribute)
else
left = n if n.send(order_attribute) > self.send
(order_attribute)
end
end
self.move_to_child_of(parent)
if left
self.move_to_right_of(left)
elsif parent.children.count > 1
self.move_to_left_of(parent.children[0])
end
else
self.move_to_root
end
end
Colin Law
2009-Jun-19 15:49 UTC
Re: what''s wrong ... syntax error ... unexpected identifer ..
2009/6/19 Erwin <yves_dufour@mac.com>:> > > got this error [rails 2.3.2, Ruby 1.8.7] > > > syntax error, unexpected tIDENTIFIER, expecting kEND > ... if n.send(order_attribute) > self.send(order_attribute) > > idoesn't like the '>' ... what's wrong ? > > > here is my action... > > def move_to_ordered_child_of(parent, order_attribute, > ascending=true) > if parent > left = nil > parent.children.each do |n| > if ascending > left = n if n.send(order_attribute) < self.send > (order_attribute) > else > left = n if n.send(order_attribute) > self.send > (order_attribute) > end > end > self.move_to_child_of(parent) > if left > self.move_to_right_of(left) > elsif parent.children.count > 1 > self.move_to_left_of(parent.children[0]) > end > else > self.move_to_root > end > endIt does not give me a syntax error. Try putting it as near the start of the file as possible in case the error is actually earlier in the file but not picked up till here, though not sure what that could be. 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@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---
Philip Hallstrom
2009-Jun-19 15:54 UTC
Re: what''s wrong ... syntax error ... unexpected identifer ..
> got this error [rails 2.3.2, Ruby 1.8.7] > > > syntax error, unexpected tIDENTIFIER, expecting kEND > ... if n.send(order_attribute) > self.send(order_attribute) > > idoesn''t like the ''>'' ... what''s wrong ? > > > here is my action... > > def move_to_ordered_child_of(parent, order_attribute, > ascending=true) > if parent > left = nil > parent.children.each do |n| > if ascending > left = n if n.send(order_attribute) < self.send > (order_attribute)Try... left = n if ( n.send(order_attribute) < self.send )> else > left = n if n.send(order_attribute) > self.send > (order_attribute) > end > end > self.move_to_child_of(parent) > if left > self.move_to_right_of(left) > elsif parent.children.count > 1 > self.move_to_left_of(parent.children[0]) > end > else > self.move_to_root > end > end > >
Colin Law
2009-Jun-19 16:11 UTC
Re: what''s wrong ... syntax error ... unexpected identifer ..
2009/6/19 Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org>:> >> got this error [rails 2.3.2, Ruby 1.8.7] >> >> >> syntax error, unexpected tIDENTIFIER, expecting kEND >> ... if n.send(order_attribute) > self.send(order_attribute) >> >> idoesn''t like the ''>'' ... what''s wrong ? >> >> >> here is my action... >> >> def move_to_ordered_child_of(parent, order_attribute, >> ascending=true) >> if parent >> left = nil >> parent.children.each do |n| >> if ascending >> left = n if n.send(order_attribute) < self.send >> (order_attribute) > > Try... > > left = n if ( n.send(order_attribute) < self.send ) >It is not that line that is blowing up, it is the one below with ''>'' Colin> > > > >> else >> left = n if n.send(order_attribute) > self.send >> (order_attribute) >> end >> end >> self.move_to_child_of(parent) >> if left >> self.move_to_right_of(left) >> elsif parent.children.count > 1 >> self.move_to_left_of(parent.children[0]) >> end >> else >> self.move_to_root >> end >> end >> > > > > > >
Philip Hallstrom
2009-Jun-19 16:18 UTC
Re: what''s wrong ... syntax error ... unexpected identifer ..
On Jun 19, 2009, at 9:11 AM, Colin Law wrote:> > 2009/6/19 Philip Hallstrom <philip-LSG90OXdqQE@public.gmane.org>: >> >>> got this error [rails 2.3.2, Ruby 1.8.7] >>> >>> >>> syntax error, unexpected tIDENTIFIER, expecting kEND >>> ... if n.send(order_attribute) > self.send(order_attribute) >>> >>> idoesn''t like the ''>'' ... what''s wrong ? >>> >>> >>> here is my action... >>> >>> def move_to_ordered_child_of(parent, order_attribute, >>> ascending=true) >>> if parent >>> left = nil >>> parent.children.each do |n| >>> if ascending >>> left = n if n.send(order_attribute) < self.send >>> (order_attribute) >> >> Try... >> >> left = n if ( n.send(order_attribute) < self.send ) >> > > It is not that line that is blowing up, it is the one below with ''>''Heh. Good point. Same thing would apply below though... Assuming like someone else said that it is this piece of code and not some other ">" somewhere...> Colin > >> >> >> >> >>> else >>> left = n if n.send(order_attribute) > self.send >>> (order_attribute) >>> end >>> end >>> self.move_to_child_of(parent) >>> if left >>> self.move_to_right_of(left) >>> elsif parent.children.count > 1 >>> self.move_to_left_of(parent.children[0]) >>> end >>> else >>> self.move_to_root >>> end >>> end >>>> >> >> >>> >> > > >