You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ActionView::Template::Error (no implicit conversion of String into Integer)
is extremely obtuse.
I'm opening this issue so that others when they see this can paste the offending code. I'd paste my example, but I forgot what it was. Then another team member of mine hit the same error and got stuck for a long time.
The process I used to solve the issue is:
Comment out lines in the template to find the offending line or lines.
Read examples super carefully and look for errors.
The text was updated successfully, but these errors were encountered:
I spent a little while scratching my head on this error tonight before I found this thread. Thought I'd leave an example, in case others find it too. I'm using a few nested partials.
Can replicate it pretty easy by doing something like this:
ActionView::Template::Error (no implicit conversion of String into Integer):
1: json.set! :pagination do
2: json.set! :currentPage, model.current_page
3: json.set! :totalPages, model.total_pages
4: json.set! :itemCount, model.total_count
10 points if you noticed what I did wrong.. Turns out it was being caused by the return type on the original partial articles/_index.json.jbuilder. The partial is returning both an array (of articles) and an object (pagination) and attempting to assign both values to a parent object 🤦
Changing the first line to return an object rather than an array fixed the issue:
There are still cases where the error message:
ActionView::Template::Error (no implicit conversion of String into Integer)
is extremely obtuse.
I'm opening this issue so that others when they see this can paste the offending code. I'd paste my example, but I forgot what it was. Then another team member of mine hit the same error and got stuck for a long time.
The process I used to solve the issue is:
The text was updated successfully, but these errors were encountered: