Rails: How I can pass variables to template resolver -


<पूर्व> # home_controller.rb वर्ग होम नियंत्रक & lt; ApplicationController prepend_view_path MyResolver.instance def some_action my_variable = true रेंडर: some_action, my_variable: my_variable end end # my_resolver.rb वर्ग MyResolver & lt; ActionView :: Resolver में सिंगलटन संरक्षित def find_templates (राज्य, उपसर्ग, आंशिक, विवरण) # do_something अगर my_variable अंत का अंत

मैं कैसे कर सकता हूँ my_variable नियंत्रक कार्रवाई से रेंडर विकल्प के रूप में टेम्पलेट रिज़ॉल्वर को

यह किस प्रकार की जानकारी है कि आप को रिज़ॉल्टर में पास करना होगा? यह मेरे लिए एक अच्छा पैटर्न की तरह नहीं दिखता है।

क्यों आप एक सिंगलटन रिज़ॉल्वर है? क्या यह उद्देश्य पर है?

आप क्या कर सकते हैं इससे पहले कि आपकी समस्या को संभाल लेना है:

  before_action: handle_resolver निजी def handle_resolver prepend_view_path MyResolver.new (your_variable) end < / कोड>   

Comments

Popular posts from this blog

python - how we can use ajax() in views.py in django? -

matlab - Using loops to get multiple values into a cell -

python - Sequence Pattern recognition with Pybrain -