मेरे पास एक नया नया रेल 4.1.1 ऐप है जहां मैं डेविस ईमेल को अनुकूलित कर रहा हूं। मैं उन्हें नई रेल ईमेल पूर्वावलोकन सुविधा पर प्रदर्शित करना चाहते हैं तो मैंने किया था निम्नलिखित:रेल 4.1 मेलर पूर्वावलोकन और कस्टम ईमेल
config.action_mailer.preview_path = "#{Rails.root}/lib/mailer_previews"
2) अपने कस्टम ईमेल UserMailer
वसीयत में निर्मित:
1) मेरी config/development.rb
फाइल करने के लिए निम्नलिखित स्निपेट जोड़ा गया app/mailers/user_mailer.rb
:
class UserMailer < Devise::Mailer
helper :application # gives access to all helpers defined within `application_helper`.
include Devise::Controllers::UrlHelpers # Optional. eg. `confirmation_url`
layout "notifications_mailer"
end
3) बदल दिया config/initializers/devise.rb
निम्नलिखित स्निपेट शामिल करने के लिए:
class UserMailerPreview < ActionMailer::Preview
def confirmation_instructions
UserMailer.confirmation_instructions(User.first, {})
end
def reset_password_instructions
UserMailer.reset_password_instructions(User.first, {})
end
def unlock_instructions
UserMailer.unlock_instructions(User.first, {})
end
end
,:
4) lib/mailer_previews
को निम्नलिखित सामग्री के साथ वर्ग UserMailerPreview
जोड़ा गया। ऐसा लगता है कि मैंने सब ठीक किया है। लेकिन तब मैं/रेल/मेलर्स/user_mailer/confirmation_instructions मार्ग पर confirmation_instructions
ईमेल के लिए पूर्वावलोकन देखने के लिए कोशिश करते हैं और मैं निम्नलिखित त्रुटि मिलती है:
undefined method `confirmation_url' for #<#<Class:0x007fa02ab808e0>:0x007fa030fb7e80>
मेरी confirmation_url.html.erb
टेम्पलेट के लिए कोड इस तरह दिखता है:
<%= t("notifications.texts.greeting") + @user.display_name %>,
<p>You can confirm your account email through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @token) %></p>
मैं क्या गलत कर रहा हूं? मुझे लगता है कि जिस तरह से मैं confirmation_url
विधि को कॉल करता हूं, उससे कुछ गलत है। कोई भी मेरी मदद कर सकता है?
आप 'confirmation_url' कहां कहते हैं? क्या आप प्रासंगिक कोड साझा कर सकते हैं जहां आपको यह त्रुटि मिल रही है। दृश्य में –
आह। – rodrigoalves
पोस्ट को अपडेट किया गया मैंने @ स्टील के सुझावों का पालन किया और इसे काम कर लिया। परिवर्तनों को प्रभावी होने के लिए मुझे सर्वर को पुनरारंभ करना पड़ा। – Besi