ruby on rails - 'method not found' after using controller decorator -
i'm trying add feature spree admin page resend shipment email.
i'm getting error,
actionview::template::error (undefined method `resend_shipment_email_admin_order_url' #<#<class:0x0000000668cf80>:0x00000006683700>): 16: </ul> 17: 18: <%= button_link_to spree.t('resend order email'), resend_admin_order_url(@order), method: :post, icon: 'email' %> 19: <%= button_link_to spree.t('resend shipment email'), resend_shipment_email_admin_order_url(@order), method: :post, icon: 'email' %> 20: </div> 21: <% end %> 22: </div>
here decorator, app/controllers/spree/orders_controller_decorator.rb,
spree::admin::orderscontroller.class_eval before_action :load_order, only: [:edit, :update, :cancel, :resume, :approve, :resend, :resend_shipment_email, :open_adjustments, :close_adjustments, :cart] def resend_shipment_email if @order.shipment_state == "shipped" shipmentmailer.shipped_email(@order.shipments.last.id).deliver flash[:success] = "shipment email resent" redirect_to :back else flash[:error] = "cannot send shipment email. order not marked shipped." redirect_to :back end end end
here's routes,
namespace :admin resources :orders, except: [:show] member post :resend_shipment_email end end end
here's view override,
deface::override.new(:virtual_path => 'spree/admin/shared/_content_header', :name => 'add_resend_shipment_email_button_to_spree_admin', :insert_bottom => "[data-hook='toolbar'], #toolbar[data-hook]", :text => " <%= button_link_to spree.t('resend order email'), resend_admin_order_url(@order), method: :post, icon: 'email' %> <%= button_link_to spree.t('resend shipment email'), resend_shipment_email_admin_order_url(@order), method: :post, icon: 'email' %> " )
here snippet rake routes,
resend_shipment_email_admin_order post /admin/orders/:id/resend_shipment_email(.:format) admin/orders#resend_shipment_email resend_admin_order post /admin/orders/:id/resend(.:format) spree/admin/orders#resend
what had fix routes file spree recognize,
spree::core::engine.routes.draw namespace :admin resources :orders, except: [:show] member post :resend_shipment_email end end end end
Comments
Post a Comment