Michael Lee Tyrrell
Michael Lee Tyrrell

Reputation: 1

Ruby on Rails Syntax Error

I'm new to rails and I can't figure out what's wrong with the syntax - it seems to be getting through the first block (for price) and is giving me an error once I hit 'score' => etc...

<% dataset = { %>
<%  'price' => [@wines.each do |wine| %>
<%                  wine.price_750 %>, 
<%              end].to_vector(:scale),%> 

<%  'score' => [@wines.each do |wine| %>
<%              if current_user.wine_ratings.scoped_by_wine_id(wine.id).exists? %>
<%              current_user.wine_ratings.find_by_wine_id(wine.id).rating_value %>,
<%              else %>
<%                  wine.rating %>,
<%              end%>
<%              end].to_vector(:scale)%>
<% }.to_dataset %>

here's the error message:

index.html.erb:13: syntax error, unexpected ';', expecting tASSOC ');'score' => [@wines.each do |wine|

index.html.erb:13: syntax error, unexpected tASSOC, expecting keyword_end ');'score' => [@wines.each do |wine|

index.html.erb:20: syntax error, unexpected '}', expecting keyword_end }.to_dataset

Anyone know what I'm doing wrong?

Upvotes: 0

Views: 152

Answers (3)

Rohit
Rohit

Reputation: 6613

Nor sure if this post is related to your error or not but when I first googled for the error which I was receiving in RoR this question was the first link. So pasting my solution :).

Missing controller Argument Error

Upvotes: 0

alexanderpine
alexanderpine

Reputation: 178

I think that you are confused as to MVC programming in general. This kind of code does not belong in the view, rather in either your controller or a view helper, but, in general, try to keep business logic like this to a minimum in your view.

Upvotes: 2

Amadan
Amadan

Reputation: 198314

Just a guess, but I would suspect erb is getting confused with the newline, and with all the opening and closing of ERb tags. Try scrapping all but the outermost tags; alternately, try killing the blank line, or surrounding it too with the crazy. I would suggest the first, since it also increases readability, speed of debugging, and people's first impressions :p

Upvotes: 0

Related Questions