1

I am trying to go over all builds objects in project (has_many relation) and set yy to be the last updated_at one with status 'completed'

The following javascript command which reside in my haml file:

var yy = #{project.builds.select{|b| b.status == 'completed'}.last.try(:updated_at)};

throw " Uncaught SyntaxError: Unexpected number" (although, I see in debug mode that it managed to get the correct value)

what is the correct way to go over my builds from javascript?

1 Answer 1

1

I guess you need quotes here:

var yy = "#{ project.builds.select{|b| b.status == 'completed'}.last.try(:updated_at) }";
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.