I’ve made the following changes to scaffolding.rb. Is it possible to
put those changes into some type of a plugin or helper or something,
instead of directly modifying the Rails source?
(and, btw, I think pagination should be removed from scaffolding. And
deletes should only happen on post requests. That’s essentially what
I’ve changed).
Thanks,
Joe
Index: vendor/rails/actionpack/lib/action_controller/scaffolding.rb
— vendor/rails/actionpack/lib/action_controller/scaffolding.rb
(revision 125)
+++ vendor/rails/actionpack/lib/action_controller/scaffolding.rb
(working copy)
@@ -99,7 +99,7 @@
module_eval <<-"end_eval", __FILE__, __LINE__
def list#{suffix}
-
@#{singular_name}_pages, @#{plural_name} = paginate
:#{plural_name}, :per_page => 10
-
@#{plural_name} = #{class_name}.find(:all) render#{suffix}_scaffold "list#{suffix}" end
@@ -109,8 +109,12 @@
end
def destroy#{suffix}
-
#{class_name}.find(params[:id]).destroy
-
redirect_to :action => "list#{suffix}"
-
@#{ singular_name } = #{ class_name }.find(params[:id])
-
if request.post?
-
@#{ singular_name}.destroy
-
flash[:notice] = "#{ class_name } was deleted."
-
redirect_to :action => "list#{suffix}"
-
end end def new#{suffix}