instance method
destroy
Ruby on Rails 2.14.1
Since v2.11.5 Last seen in v2.14.1Signature
destroy()
No documentation comment.
Source
# File lib/generators/rails/templates/controller.rb, line 56
def destroy
@<%= orm_instance.destroy %>
respond_to do |format|
format.html { redirect_to <%= index_helper %>_path, notice: <%= %("#{human_name} was successfully destroyed.") %>, status: :see_other }
format.json { head :no_content }
end
end
private
# Use callbacks to share common setup or constraints between actions.
def set_<%= singular_table_name %>
<%- if Rails::VERSION::MAJOR >= 8 -%>
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params.expect(:id)") %>
<%- else -%>
@<%= singular_table_name %> = <%= orm_class.find(class_name, "params[:id]") %>
<%- end -%>
end
# Only allow a list of trusted parameters through.
def <%= "#{singular_table_name}_params" %>
<%- if attributes_names.empty? -%>
params.fetch(<%= ":#{singular_table_name}" %>, {})
<%- elsif Rails::VERSION::MAJOR >= 8 -%>
params.expect(<%= singular_table_name %>: [ <%= permitted_params %> ])
<%- else -%>
params.require(<%= ":#{singular_table_name}" %>).permit(<
Defined in lib/generators/rails/templates/controller.rb line 56
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Object