Sha256: 63747071612f38a334c77df41d6dc1c699ce53db68d0ec407b1caf42e3ed7036
Contents?: true
Size: 782 Bytes
Versions: 2
Compression:
Stored size: 782 Bytes
Contents
module SimpleCrud def class_name(instance) instance.class.name.underscore.humanize end def create_(instance, path, r) # Save the instance, Redirect_to if save successful, #render template if not successful if instance.save redirect_to path, notice: class_name(instance) + " created." else render r end end def update_(instance, strong_params, path) # Update the instance, Redirect_to if successful, # Always renders edit if instance.update(strong_params) redirect_to path, notice: class_name(instance) + " updated." else render :edit end end def destroy_(instance, path) # Delete instance, Redirect_to after delete instance.destroy redirect_to path, notice: class_name(instance) + " deleted." end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
simple_crud-0.1.1 | lib/simple_crud.rb |
simple_crud-0.0.2 | lib/simple_crud.rb |