I have two controllers having update action. Both the action have similar code and I am in a confusion how to remove duplication and make it dry. Code climate showing duplication problem in this one. Here are the details.
Controller 1: respond_to do |format| if @business_profile.update(business_profiles_params) format.html { redirect_to settings_path, notice: t('setting_successful_message') } else format.html { redirect_to settings_path, alert: t('setting_failure_message') end end
Controller 2: respond_to do |format| if @contact.update(contact_params) format.html { redirect_to contacts_path, notice: t('contact_successful_message') } else format.html { redirect_to contacts_path, alert: t('contact_failure_message') end end
so I want this similar content to be in one.