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?

Muky
  • 3,584
  • 3
  • 19
  • 20

1 Answers1

1

I guess you need quotes here:

var yy = "#{ project.builds.select{|b| b.status == 'completed'}.last.try(:updated_at) }";
Rustam Gasanov
  • 15,290
  • 8
  • 59
  • 72