0

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?

3 Answers 3

2

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.

Sign up to request clarification or add additional context in comments.

2 Comments

Yeah, I'm still trying to understand a lot of the basic concepts - I'll try and move it to the controller or view helper. thanks!
Sorry, didn't mean to be rude or mean at all! :)
0

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

1 Comment

Killing the blank line got me to another error - so that seemed to be part of the problem. I'll try scrapping the extra erb tags as well - see if that gets me anywhere. Thanks!
0

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

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.