Skip to content

Instantly share code, notes, and snippets.

@slayer
Created December 16, 2009 15:05
Show Gist options
  • Save slayer/257883 to your computer and use it in GitHub Desktop.
Save slayer/257883 to your computer and use it in GitHub Desktop.
def destroy
if params[:ids]
@models = Model.find(:all, :conditions => { :id => params[:ids] })
@models.each { |m| m.destroy }
else
@model = Tracker.find(params[:id])
@model.destroy
end
end
%h1.heading
Listing users
= grid(@users_grid, :show_filters => :always) do |g|
- g.column :column_name => 'checkbox'
- g.column :column_name => 'ID', :attribute_name => 'id'
- g.column :column_name => 'Name', :attribute_name => 'name'
- g.column :column_name => 'EMail', :attribute_name => 'email'
- g.column do |user|
- link_to "Destroy", { :action => :destroy, :id => user.to_param }, :method => :delete, :confirm => "Are you sure?"
- g.header
- button_to "Delete selected", { :action => "delete" }, :confirm => "Are you sure?", :method => :delete
- g.footer
- button_to "Delete selected", { :action => "delete" }, :confirm => "Are you sure?", :method => :delete
OR (with header/footer columns)
- g.header
- g.column
- button_to "Delete selected", { :action => "delete" }, :confirm => "Are you sure?", :method => :delete
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment