मैं निम्नलिखित चीजों को अनुकूलित करना चाहता हूं
- क्रिया का नाम जैसे "उपयोगकर्ता जोड़ें" => "उपयोगकर्ता बनाएँ", "उपयोगकर्ता संपादित करें" => "अपडेट उपयोगकर्ता" आदि
- "उपयोगकर्ता सफलतापूर्वक बनाया गया" => "ग्राहक सफलतापूर्वक बनाया गया" जैसे डिलीट, क्रिएट और एडिट पर सक्सेस मैसेज
- एडिट और डिलीट के बगल में शो पेज पर एक क्रिएट बटन जोड़ें
2 जवाब
हाँ यह संभव है।
क्रिया का नाम जैसे "उपयोगकर्ता जोड़ें" => "उपयोगकर्ता बनाएँ", "उपयोगकर्ता संपादित करें" => "अपडेट उपयोगकर्ता" आदि
f.actions
होने के बजाय, आप कर सकते थे
<%= f.actions do %>
<%= f.action :submit, as: :button, label: 'Create User' %>
<%= f.action :cancel, as: :link %> # change it to button if needed
<% end %>
ActiveAdmin फॉर्मटैस्टिक, यहां और पढ़ें का उपयोग करता है।
सक्सेस मैसेज डिलीट, क्रिएट एंड एडिट जैसे "यूजर सफलतापूर्वक बनाया गया" => "ग्राहक सफलतापूर्वक बनाया गया"
def create # or any other action
super do |format| # this is important - override the original implementation
redirect_to(
admin_users_path,
notice: 'Your custom message for successful user creation'
) and return
end
end
आप यह भी आज़मा सकते हैं:
def create # or any other action
super do |format| # this is important - override the original implementation
flash[:notice] = 'Your custom message for successful user creation'
# you do understand, that if you have different routes you should change this, right?
redirect_to admin_users_path
end
end
एडिट और डिलीट के बगल में शो पेज पर एक क्रिएट बटन जोड़ें
action_item only: :show do
link_to 'Create new user', new_admin_users_path
end
मैं दूसरे के लिए उत्तर जोड़ रहा हूं (ऊपर से संदर्भ), लेकिन ऊपर सत्यापन त्रुटियों पर काम नहीं कर रहा है इसलिए मैं इसे अनुकूलित करता हूं जिससे आपको बेहतर मदद मिल सके
controller do
def update
super do |format|
if !@your_object.errors.any?
redirect_to(
admin_my_localities_path,
notice: 'custom message.'
) and return
end
end
end
def destroy
super do |format|
if !@your_object.errors.any?
redirect_to(
admin_my_localities_path,
notice: 'custom message.'
) and return
else
redirect_to(
admin_my_localities_path,
alert: 'custom error.'
) and return
end
end
end
end
संबंधित सवाल
नए सवाल
ruby-on-rails
रूबी ऑन रेल्स रूबी में लिखा गया एक ओपन सोर्स फुल-स्टैक वेब एप्लिकेशन फ्रेमवर्क है। यह लोकप्रिय एमवीसी फ्रेमवर्क मॉडल का अनुसरण करता है और इसे "कॉन्फिगरेशन ओवर कॉन्फिगरेशन" अप्रोच डेवलपमेंट के दृष्टिकोण के लिए जाना जाता है।