Ruby Block Syntax Error [duplicate]

Try this:

version(:full)   { process(:resize_to_limit => [960, 960]) }
version(:half)   { process(:resize_to_limit => [470, 470]) }
version(:third)  { process(:resize_to_limit => [306, 306]) }
version(:fourth) { process(:resize_to_limit => [176, 176]) }

You have a precedence problem. The { } block binds tighter than a do...end block and tighter than a method call; the result is that Ruby thinks you’re trying to supply a block as an argument to a symbol and says no.

You can see a clearer (?) or possibly more familar example by comparing the following:

[1, 2, 3].inject 0  { |x, y| x + y }
[1, 2, 3].inject(0) { |x, y| x + y }

Leave a Comment