Guest User

Untitled

a guest
Apr 25th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.33 KB | None | 0 0
  1. Index: lib/extensions/action_controller_rendering.rb
  2. ===================================================================
  3. --- lib/extensions/action_controller_rendering.rb (revision 114)
  4. +++ lib/extensions/action_controller_rendering.rb (revision 116)
  5. @@ -9,15 +9,12 @@
  6. path_val = params[:adapter] || args[0][:action]
  7. # ACC I'm setting use_full_path to false here and rewrite_template_path_for_active_scaffold has been
  8. # modified to return an absolute path
  9. + show_layout = args[0][:partial] ? false : true
  10. render :file => rewrite_template_path_for_active_scaffold(path_val),
  11. :locals => {:payload => render_to_string(args.first, &block)},
  12. - :use_full_path => false
  13. + :use_full_path => false,
  14. + :layout => show_layout
  15. @rendering_adapter = nil # recursion control
  16. - elsif self.class.uses_active_scaffold? && args[0] && args[0][:file]
  17. - # ACC I'm adding this elsif statement so that I can rewrite the file path and set use_full_path to true
  18. - args[0][:file] = rewrite_template_path_for_active_scaffold(args[0][:file])
  19. - args[0][:use_full_path] = true
  20. - render_without_active_scaffold(args[0])
  21. else
  22. render_without_active_scaffold(*args, &block)
  23. end
  24. @@ -42,8 +39,6 @@
  25. private
  26.  
  27. def rewrite_template_path_for_active_scaffold(path)
  28. - # test for the actual file
  29. - return path if template_exists? default_template_name(path)
  30. base = File.join RAILS_ROOT, 'app', 'views'
  31. # check the ActiveScaffold-specific directories
  32. active_scaffold_config.template_search_path.each do |template_path|
  33. @@ -52,12 +47,12 @@
  34. # ACC I'm using this regex directory search because I don't know how to hook into the
  35. # rails code that would do this for me. I am assuming here that path is a non-nested
  36. # partial, so my regex is fragile, and will only work in that case.
  37. - template_file = Dir.entries(search_dir).find {|f| f =~ /^_?#{path}/ }
  38. + template_file = Dir.entries(search_dir).find {|f| f =~ /^#{path}/ }
  39. # ACC pick_template and template_exists? are the same method (aliased), using both versions
  40. # to express intent.
  41. - return pick_template(template_file) if template_exists?(template_file)
  42. + return File.join(search_dir, template_file) if template_exists?(template_file)
  43. end
  44. return path
  45. end
  46. end
  47. -end
  48. +end
  49. \ No newline at end of file
  50. Index: lib/extensions/action_view_rendering.rb
  51. ===================================================================
  52. --- lib/extensions/action_view_rendering.rb (revision 114)
  53. +++ lib/extensions/action_view_rendering.rb (revision 116)
  54. @@ -73,6 +73,14 @@
  55. alias_method :render_partial, :render_partial_with_active_scaffold
  56.  
  57. private
  58. + # FIXME hack, this has been removed in edge rails
  59. + def partial_pieces(partial_path)
  60. + if partial_path.include?('/')
  61. + return File.dirname(partial_path), File.basename(partial_path)
  62. + else
  63. + return controller.class.controller_path, partial_path
  64. + end
  65. + end
  66.  
  67. def rewrite_partial_path_for_active_scaffold(partial_path)
  68. path, partial_name = partial_pieces(partial_path)
  69. Index: lib/helpers/form_column_helpers.rb
  70. ===================================================================
  71. --- lib/helpers/form_column_helpers.rb (revision 114)
  72. +++ lib/helpers/form_column_helpers.rb (revision 116)
  73. @@ -182,9 +182,18 @@
  74. ## Form column override signatures
  75. ##
  76.  
  77. + # FIXME hack, this has been removed in edge rails
  78. + def active_scaffold_partial_pieces(partial_path)
  79. + if partial_path.include?('/')
  80. + return File.dirname(partial_path), File.basename(partial_path)
  81. + else
  82. + return controller.class.controller_path, partial_path
  83. + end
  84. + end
  85. +
  86. def override_form_field_partial?(column)
  87. - path, partial_name = partial_pieces(override_form_field_partial(column))
  88. - file_exists? File.join(path, "_#{partial_name}")
  89. + path, partial_name = active_scaffold_partial_pieces(override_form_field_partial(column))
  90. + File.exists? File.join(path, "_#{partial_name}")
  91. end
  92.  
  93. # the naming convention for overriding form fields with partials
Add Comment
Please, Sign In to add comment