I have a problem with params visibility the function find_agency
:
Code:
require 'sinatra/base'
module Sinatra
module AgencyRightsHelper
def self.find_agency
@agency = nil
if !params[:agency_id].nil? then
@agency = Agency.find(params[:agency_id]) and return
end
end
def before_get_agency rights_params
AgencyRightsHelper::find_agency
end
end
helpers AgencyRightsHelper
end
Error:
2017-05-10 00:01:26 - NoMethodError - undefined method `params' for Sinatra::AgencyRightsHelper:Module:
/Users/dali/perso/spacieux-be/app/helpers/agency_rights_helper.rb:18:in `before_get_agency'
/Users/dali/perso/spacieux-be/app/helpers/rights_helper.rb:61:in `before_action'
params is visible in other helpers function where no self is used but I feel obliged to use it the re-use a function in the helper itself.