Guest User

Untitled

a guest
Feb 21st, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.20 KB | None | 0 0
  1. #
  2. # Imagine a few slices...
  3. #
  4.  
  5. #
  6. # Watch out: Merb code ahead
  7. #
  8.  
  9. class PersonProfile
  10. def create(profile_attributes)
  11. # ...
  12.  
  13. # namespaced/scoped to slice routes table
  14. redirect slice_url(:profile, @profile)
  15. end
  16. end
  17.  
  18. class ProjectProfile
  19. def create(profile_attributes)
  20. # ...
  21.  
  22. # namespaced/scoped to slice routes table
  23. redirect slice_url(:profile, @profile)
  24. end
  25. end
  26. end
  27.  
  28.  
  29.  
  30.  
  31. #
  32. # Watch out: Rails code ahead
  33. #
  34.  
  35. class PersonProfile
  36. def create
  37. # ...
  38.  
  39. # namespacing/scoping would take a prefix
  40. # which means evaluation scope matters => implementation is fairly complex
  41. redirect_to person_profile_url(@profile)
  42. end
  43. end
  44.  
  45. class ProjectProfile
  46. def create
  47. # namespacing/scoping would take a prefix
  48. # which means evaluation scope matters => implementation is fairly complex
  49. redirect_to project_profile_url(@profile)
  50. end
  51. end
  52. end
  53.  
  54.  
  55. #
  56. # Ideas
  57. #
  58.  
  59. Rails3::Router.prepare do
  60. slice :person do
  61. resource :profile
  62. end
  63.  
  64. slice :project do
  65. resource :profile
  66. end
  67. end
  68.  
  69. #
  70. # Results into
  71. #
  72. # person_profile_url
  73. # edit_person_profile_url
  74. # follow_person_profile_url
  75. # ...
  76. #
Add Comment
Please, Sign In to add comment