Redirecting to the appropriate URL for some type of notification
Suggestions:


Break long methods into simple parts;
Avoid unnecessary local variables;
Use single quotes for strings without interpolation;
Move repeated parts of code into separate methods.


Code:

def notification_redirection_path(notification)
  notifiable_type = notification.notifiable_type
  notifiable_id = notification.notifiable_id

  case notification.action
  when 'commented'
    case notifiable_type
    when 'Post'
      posts_path(anchor: "post_#{notifiable_id}")#{}"/posts#post_#{notifiable_id}"
    when 'Product'
      product_path(notifiable_id, anchor: 'comment-panel')#/products/#{notifiable_id}#comment-panel"
    when 'ProductLead'
      product_product_lead_path(*lead_params(notifiable_id), anchor: 'comment-panel')#{}"/products/#{product_id}/#{notifiable_type}/#{notifiable_id}#comment-panel"
    when 'ProductCustomer'
      product_product_customer_path(*customer_params(notifiable_id), anchor: 'comment-panel') #/products/#{product_id}/#{notifiable_type}/#{notifiable_id}#comment-panel"
    end
  when 'invited'
    if notifiable_type == 'Product'
      product_path(notifiable_id, anchor: 'product-invitation-well')
    elsif notifiable_type == 'ProductCustomer'
      product_product_customer_path(*customer_params(notifiable_id))
    end
  when 'accepted'
    if notifiable_type == 'Product' #team member invitation
      product_product_owner_panels_path(notifiable_id)
    elsif notifiable_type == 'ProductCustomer' #referencer invitation
      product_product_owner_panels_path(*customer_params(notifiable_id).first)
    end
  when 'wrote'
    product_product_customer_path(*customer_params(notifiable_id))
  end
end

private

def customer_params(notifiable_id)
  [ProductCustomer.find(notifiable_id).product_id, notifiable_id]
end

def lead_params(notifiable_id)
  [ProductLead.find(notifiable_id).product_id, notifiable_id]
end