Advertisement
Guest User

Untitled

a guest
May 26th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.79 KB | None | 0 0
  1. <%= link_to checking_decreasing_user_notifications_path(
  2. current_user,
  3. notifiable_type: notification.notifiable_type,
  4. notifiable_id: notification.notifiable_id,
  5. notification_action: notification.action
  6. ) do %>
  7.  
  8. def checking_decreasing
  9. current_user.decreasing_comment_notification_number(
  10. params[:notifiable_type],
  11. params[:notifiable_id]
  12. )
  13. redirect_to notification_redirection_path(
  14. params[:notifiable_type],
  15. params[:notifiable_id],
  16. params[:notification_action]
  17. )
  18. end
  19.  
  20. def notification_redirection_path(notifiable_type, notifiable_id, action)
  21. if action == "commented"
  22. if notifiable_type == "ProductCustomer"
  23. product_customer = ProductCustomer.find(notifiable_id)
  24. product_id = product_customer.product_id
  25. elsif notifiable_type == "ProductLead"
  26. product_lead = ProductLead.find(notifiable_id)
  27. product_id = product_lead.product_id
  28. end
  29. route = case notifiable_type
  30. when "Post"
  31. posts_path(anchor: "post_#{notifiable_id}")#{}"/posts#post_#{notifiable_id}"
  32. when "Product"
  33. product_path(notifiable_id, anchor: "comment-panel")#/products/#{notifiable_id}#comment-panel"
  34. when "ProductLead"
  35. product_product_lead_path(product_id, notifiable_id, anchor: "comment-panel")#{}"/products/#{product_id}/#{notifiable_type}/#{notifiable_id}#comment-panel"
  36. when "ProductCustomer"
  37. product_product_customer_path(product_id, notifiable_id, anchor: "comment-panel") #/products/#{product_id}/#{notifiable_type}/#{notifiable_id}#comment-panel"
  38. end
  39. elsif action == "invited"
  40. product_path(notifiable_id, anchor: "product-invitation-well")
  41. elsif action == "accepted"
  42. product_product_users_path(notifiable_id)
  43. end
  44. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement