Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting: "Couldn't find SessionsHelper, expected it to be defined in helpers/sessions_helper.rb"

I am getting the following in my log file upon loading /login/.

Started GET "/login" for 120.138.93.108 at 2016-01-02 03:06:24 +0000

ActionController::RoutingError (Couldn't find SessionsHelper, expected it to be defined in helpers/sessions_helper.rb): app/controllers/application_controller.rb:1:in' app/controllers/sessions_controller.rb:1:in'

However, sessions_helper.rb does exist in the helpers folder. Furthermore, application_controller.rb and sessions_controller.rb are defined as Classes and the session_helper.rb as module.

What could be wrong?

like image 377
Thierry M. Avatar asked Feb 08 '23 04:02

Thierry M.


1 Answers

I had a similar problem:

Couldn't find AgileTeamsHelper, expected it to be defined in helpers/agile_teams_helper.rb

It turns out I had this defined in my helper:

module AgileTeamHelper
  def td_color(text)
    if text == "Green"
      "green-background"
    elsif text == "Yellow"
      "yellow-background"
    elsif text == "Red"
      "red-background"
    end
  end
end

Instead of:

module AgileTeamsHelper # <-- (Notice the extra s after teams)
  def td_color(text)
    if text == "Green"
      "green-background"
    elsif text == "Yellow"
      "yellow-background"
    elsif text == "Red"
      "red-background"
    end
  end
end

In this case I was missing the 's' in 'AgileTeamsHelper'. I believe that rails looks for a module with the same as the helper, but camel cased. IE. 'agile_teams_helper'.camelize -> "AgileTeamsHelper"

like image 66
ryanjones Avatar answered Apr 09 '23 18:04

ryanjones