I''ve just finished a toy project that I call "righteously
ubiquitous
javascript":
    https://github.com/rdpoor/righteous_ujs
and the experience has convinced me that Rails controllers need a
#delete method that parallels the contracts of the #new and #edit
methods.  To explain: The three "verbs" that cause a change to model
state are:
CREATE a model instance
MODIFY a model instance
DELETE a model instance
For each verb, the controller needs to implement TWO methods.  The first
method fields the request from the user to initiate the action, to which
the controller responds by rendering a GUI element that allows the user
to complete the command.  The second method is the result of submitting
the GUI element.
That''s actually the contract of #new and #edit:
#new => render a GUI element that calls #create when submitted
#edit => render a GUI element that calls #update when submitted
The problem is with DELETE (aka #destroy).  It doesn''t follow this
pattern, but it should: the controller lacks a method that renders a GUI
element.  It OUGHT to be:
#delete => render a GUI element that calls #destroy when submitted
Absent a #delete method, the Rails ends up relying on Javascript to
generate the GUI element that calls #destroy, which is Not Nice in a
system that claims to implement ubiquitous javascript.
This could easily be fixed by adding a #delete method to
ApplicationController which parallels #new and #edit.    It would avoid
the issue about requiring Javascript, and as a side effect, would make
it really easy for newcomers to understand the relationship between:
#new => #create
#edit => #update
#delete => #destroy
Make sense?  Is DHH listening?  :)
Peace out.
- ff
-- 
Posted via http://www.ruby-forum.com/.
-- 
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.
You can easily add a delete method to your controller: def delete @post = Post.find(params[:id]) end Then add it to your routes as well: resources :posts do get ''delete'', :on => :member end And you''re done -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/J_xMTEvvFBYJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer wrote in post #1038479:> You can easily add a delete method to your controller:... which is exactly what I did in the cited code example. I''m not sure how to interpret your reply. Sure it''s trivial to add. Are you claiming that a delete method should NOT become part of the standard ActiveController? -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I apologize... I guess I wasn''t sure what you were asking. ActionController::Base doesn''t have *any* methods included. Not even the index, new, edit, etc. The only methods available are the ones you add in your application. So adding delete method to ActionController doesn''t really make sense. The delete method could be added to the default set of resourceful routes so you wouldn''t need to add it to your routes manually, which is what I think you were referring to? I can definitely see your case for wanting to do this. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/3jHfWAvnwrkJ. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Tim Shaffer wrote in post #1038731:> I apologize... I guess I wasn''t sure what you were asking.No problem!> ActionController::Base doesn''t have *any* methods included.You''re right -- I mis-spoke: s/"ActionController::Base"/"standard Rails distribution"/g In addition to the resourceful routes, you''d need extensions to the various generators and templates, but yep, that''s what I''m arguing for.> I can definitely see your case for wanting to do this.Upon reflection, the right thing to do would be to open a lighthouse ticket and let the pros decide. Wish me luck! :) - ff -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
I guess FF''s question was about resourceful routing, like in routing with resources :events I like the idea. By the way, the issues are not on Lighthouse anymore but on GitHub: https://github.com/rails/rails/issues Alexey. -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
Alexey Muranov wrote in post #1038755:> I like the idea. > > By the way, the issues are not on Lighthouse anymore but on GitHub: > https://github.com/rails/rails/issuesRight you are. So, feeling a little like David facing off against Goliath, I''ve submitted a ticket: https://github.com/rails/rails/issues/4234 I hope they go gentle on me! - ff -- Posted via http://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.