Question

Fist of all I'm newbie to rails.
I have this in SessionsController:

def method
  sign_in 'user'
end

And this in SessionsHelper:

def sing_in(user)
    ......
end

So Googling and reading some answers on stackoverflow let me to try something like this:
Including the 'SessionsHelper' to the SessionsController and even tried to put it in 'ApplicationController' like this:

class ApplicationController < ActionController::Base

  protect_from_forgery
  include SessionsHelper

  def handle_unverified_requests
    sign_out
    super
  end
end

But I'm getting

NoMethodError : undefined method `sign_in' for SessionsController:0x007eff2004fcd8

Also few questions:
1) What's the point/difference in putting few methods in Heplers and few in Controllers? Is it a security issue or what?
2) I also tried puting the sign_in method in the SessionsController as i read in stackoverflow that methods defined in controllers can be accessed in views. so to avoid any problems in the views I used

helper_method

but still the same NoMethodError
3) THe best and easy way to access the helper methods in controllers?

So where am I going wrong.
I'm using Rails 3.2.11 and Ruby 2.0.0p0

Was it helpful?

Solution

Looks like a typo: your helper method is 'sing_in' instead of 'sign_in'.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top