Modifying scaffold method

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).


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}"

@@ -109,8 +109,12 @@

       def destroy#{suffix}
  •        #{class_name}.find(params[:id]).destroy
  •        redirect_to :action => "list#{suffix}"
  •        @#{ singular_name } = #{ class_name }.find(params[:id])
  •        if
  •          @#{ singular_name}.destroy
  •          flash[:notice] = "#{ class_name } was deleted."
  •          redirect_to :action => "list#{suffix}"
  •        end
         def new#{suffix}

Hey Joe:
scaffolding works great to show a demo of how rails is cool :slight_smile:

But when it comes to real application , we always end up changing those
classes. So use scaffolding as a starting point. Dont hesitate to change
BUT REMEMBER to back ur changes with unit and functional tests)

–Siva J.
My First Rails Project.
Education Through Collabration

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs