Application and route helpers stopped working after upgrading to version 1.2.7
Closed this issue · 2 comments
Hey folks!
I'm running a Rails 6 app with madmin. I upgraded madmin from version 1.2.0 to version 1.2.7 since I wanted to add the search form to my madmin index pages.
After the upgrade, however, the resource-specific madmin pages that I had created started breaking because apparently the route and application helpers don't seem to be loaded.
In my views/madmin/lessons/index.html.erb
file, for instance, I have this line
<%= link_to madmin_lesson_path(lesson), class: 'w-full' do %>
That is throwing this error
undefined local variable or method `madmin_lessons_path' for #<Class:0x000000012273dc00>:0x0000000122737e18>
If I add the route helpers to the madmin Lessons controller
module Madmin
class LessonsController < Madmin::ResourceController
include Rails.application.routes.url_helpers
Then that error goes away. However, things break again when an application helper is encountered
<%= formatted_duration(lesson.duration) %>
Which generates this error
undefined method `formatted_duration' for #<#<Class:0x00000001227d4c68>:0x00000001227ce660>
This time, however, adding include ApplicationHelper
doesn't seem to do the trick.
Any idea of why this might be happening?
you should use main_app.madmin_lesson_path(lesson)
Fair! Thanks 🙏