+ def created_html_format format, redirect_url = nil
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.created', :model => @my_model_class.model_name.human)
+ redirect_to (redirect_url ? redirect_url : @item)
+ }
+ end
+
+ def created_json_format format
+ format.json {
+ render json: @item.to_json(@my_model_class.show_json_opt), status: :created, location: @item
+ }
+ end
+
+ def not_created_html_format format
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
+ render_form
+ }
+ end
+
+ def not_created_json_format format
+ format.json {
+ render json: @item.errors, status: :unprocessable_entity
+ }
+ end
+
+ def render_create redirect_url = nil
+ if @item.save
+ respond_to do |format|
+ created_html_format format, redirect_url
+ created_json_format format
+ end
+ else
+ respond_to do |format|
+ not_created_html_format format
+ not_created_json_format format
+ end
+ end
+ end
+
+ def leaf_created_html_format format, redirect_url
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.created', :model => @my_model_class.model_name.human)
+ redirect_to redirect_url
+ }
+ end
+
+ def leaf_not_created_html_format format, redirect_url
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.not_created', :model => @my_model_class.model_name.human)
+ redirect_to redirect_url
+ }
+ end
+
+ def leaf_render_create redirect_url
+ if @item.store @operators
+ respond_to do |format|
+ leaf_created_html_format format, redirect_url
+ created_json_format format
+ end
+ else
+ respond_to do |format|
+ leaf_not_created_html_format format, redirect_url
+ not_created_json_format format
+ end
+ end
+ end
+
+ def updated_html_format format, redirect_url = nil
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.updated', :model => @my_model_class.model_name.human)
+ redirect_to (redirect_url ? redirect_url : @item)
+ }
+ end
+
+ def updated_json_format format
+ format.json {
+ head :ok
+ }
+ end
+
+ def not_updated_html_format format
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
+ render_form
+ }
+ end
+
+ def not_updated_json_format format
+ format.json {
+ render json: @item.errors, status: :unprocessable_entity
+ }
+ end
+
+ def render_update redirect_url = nil
+ if @item.save
+ respond_to do |format|
+ updated_html_format format, redirect_url
+ updated_json_format format
+ end
+ else
+ respond_to do |format|
+ not_updated_html_format format
+ not_updated_json_format format
+ end
+ end
+ end
+
+ def leaf_updated_html_format format, redirect_url
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.updated', :model => @my_model_class.model_name.human)
+ redirect_to redirect_url
+ }
+ end
+
+ def leaf_not_updated_html_format format, redirect_url
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.not_updated', :model => @my_model_class.model_name.human)
+ redirect_to redirect_url
+ }
+ end
+
+ def leaf_render_update ot, redirect_url
+ if @item.store @operators, ot
+ respond_to do |format|
+ leaf_updated_html_format format, redirect_url
+ updated_json_format format
+ end
+ else
+ respond_to do |format|
+ leaf_not_updated_html_format format, redirect_url
+ not_updated_json_format format
+ end
+ end
+ end
+
+ def destroyed_html_format format, redirect_url
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.destroyed', :model => @my_model_class.model_name.human)
+ redirect_to redirect_url
+ }
+ end
+
+ def destroyed_json_format format
+ format.json {
+ head :ok
+ }
+ end
+
+ def not_destroyed_html_format format
+ format.html {
+ flash[:notice] = I18n.t('flash.notice.not_destroyed', :model => @my_model_class.model_name.human)
+ redirect_to @item
+ }
+ end
+
+ def not_destroyed_json_format format
+ format.json {
+ render json: @item.errors, status: :unprocessable_entity
+ }
+ end
+
+ def render_destroy redirect_url = nil
+ if @item.destroy
+ respond_to do |format|
+ destroyed_html_format format, redirect_url
+ destroyed_json_format format
+ end
+ else
+ respond_to do |format|
+ not_destroyed_html_format format
+ not_destroyed_json_format format
+ end
+ end
+ end
+