简体   繁体   中英

Rails How to access “params” inside a module method that it's inside a helper module

I need to access params inside a method that it's in a module that it'is inside a module help. For example.

module ApplicationHelper
  module ExampleModule
    extend self

    def an_example_method
      //access params here
    end
  end
end

How to do that?

in my opinion the simplest thing to do would be to pass the params like this

module ApplicationHelper module ExampleModule extend self

def an_example_method(params)
  params.each do |param|
    puts param
  end
  //access params here
end

end end

now form your coltroller you can call the an_example_method mthod like this

ExampleModule.an_example_method(params)

I hope that this helps

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM