-
I use avram with kemal, following is a example. e.g. i create a errors like this:
When i check it type use typeof, it is It should work like this, because auto-splatting, right? x = {:x => [100, 200], :y => [300, 400]}
x.each do |name, errors|
p name, errors.join(", ")
end
Then, i try to render it in ECR template, like this: <div style="color: red">
<% errors.each do |name, errors| %>
<%= name %> <%= errors.join(", ") %>
<% end %>
</div> It raise error like this: 30 | <% errors.each do |name, errors| %>
^
Error: too many block parameters (given 2, expected maximum 1) Why? thank you. |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Guess: Try outputting the value of errros type. Something like: Also, note that in the first snippet you have something called |
Beta Was this translation helpful? Give feedback.
-
Thank you. @asterite Okay, i add p! debug in both ECR template and cursor block, please check screenshot. Following is log output: typeof(errors) # => Hash(Symbol, Array(String)) Following is ECR output: Hash(Symbol, Array(String)) {:password_confirmation => ["must match"]} Both of them is same exactly.
Okay, i create a new example for this. errors = {:password_confirmation => ["error1"]}
p! typeof(errors)
errors.each do |name, errors|
p name, errors
end It works, following is result: typeof(errors) # => Hash(Symbol, Array(String))
:password_confirmation
["error1"] Why ECR not work? <div style="color: red">
<% errors.each do |name, errors| %>
<%= name %>
<% end %>
</div> |
Beta Was this translation helpful? Give feedback.
-
Oops! , it my fault, because i have code like low level error! |
Beta Was this translation helpful? Give feedback.
Oops! , it my fault, because i have code like
errors = [] of String
in another kemal block which share same ECR view file and pass different type variable into it.low level error!