Alex Gutteridge
4/24/2008 3:35:00 PM
On 24 Apr 2008, at 16:20, erik wrote:
> The following piece of code returns:
> syntax error, unexpected kELSE, expecting kEND
>
> When I delete this block of code all works well - I have read that
> this may be an issue with copied or pasted code, UTF-8 issues etc....
>
> I have tried all of these - is there simply something wrong with my
> code that I am not seeing?
>
> <% if c.amount < 500 %>
> <% @project.budgmonthexpends.find(:all, :conditions =>
> [:year_id == c.year_id]).each do |d| %>
> <% else %> <!-- Error is occuring here -->
> <%@project.budgmonthexpends.find(:all, :conditions => :year_id
> == c.year_id).each do |d|%>
> <% end %>
>
> Thanks,
> Erik
You never finish (or do anything with) the block from the line above,
you have to end that block with 'end' before your 'else' statement.
if c.amount < 500
@project.budgmonthexpends.find(:all, :conditions => [:year_id ==
c.year_id]).each do |d|
end
else
@project.budgmonthexpends.find(:all, :conditions => :year_id ==
c.year_id).each do |d|
end
end
Is valid code (though still gibberish since you're not doing anything
with the two each blocks). Hope that helps.
Alex Gutteridge
Department of Biochemistry
University of Cambridge