Rails: method defined in application_helper.rb not recognized by categories_controller.rb -
more newbie issues.
i understand if define method in application helper, available entire app code.
in applicaton helper, have:
def primary_user_is_admin if current_user user_login_roles = json.parse(current_user.role) if user_login_roles["admin"] return 1 end end return nil end
if call categories_controller:
if !primary_user_is_admin redirect_to root_url end
i error message: undefined local variable or method `primary_user_is_admin'
this happens if put primary_user_is_admin code in registrations_helper.rb file
however, if use in of views (views/user/edit.html.erb instance)
<% if primary_user_is_admin %> <% end >
then works. missing?
helpers not included controller default. can
include applicationhelper
to gain access methods in applicationhelper module. previous discussion has bunch of useful solutions accessing helpers in controller.
Comments
Post a Comment