Sha256: 90a03e560d4a2704f2122c82399567a938b1f4da2275f098dccb55bf5c640a0f
Contents?: true
Size: 1.34 KB
Versions: 2
Compression:
Stored size: 1.34 KB
Contents
# encoding: utf-8 module CRUDMixin def index(&block) raise ArgumentError, "You have to provide a block" if block.nil? set_context_value(collection_name, block.call) autorender end def show(&block) raise ArgumentError, "You have to provide a block" if block.nil? set_context_value(collection_name, block.call) autorender end def new(&block) raise ArgumentError, "You have to provide a block" if block.nil? set_context_value(collection_name, block.call) autorender end def edit(&block) raise ArgumentError, "You have to provide a block" if block.nil? set_context_value(collection_name, block.call) autorender end def create(notice = "Created successfully", error = "Can't create", &block) raise ArgumentError, "You have to provide a block" if block.nil? object = block.call if object.save message[:notice] = notice redirect url(named_route, object) else message[:error] = error render_relative "show" end end def update(notice = "Updated successfully", error = "Can't update", &block) raise ArgumentError, "You have to provide a block" if block.nil? object = block.call if object.save message[:notice] = notice redirect url(named_route, object) else message[:error] = error render_relative "show" end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
rango-0.2.6 | lib/rango/mixins/crud.rb |
rango-0.2.5.1 | lib/rango/mixins/crud.rb |