app/controllers/carnival/base_admin_controller.rb in carnival-0.0.36 vs app/controllers/carnival/base_admin_controller.rb in carnival-0.0.37

- old
+ new

@@ -17,15 +17,15 @@ presenter.parse_special_scope params[:special_scope] end respond_to do |format| format.html do |render| - begin - render 'index' - rescue + # begin + # render 'index' + # rescue render '/carnival/index' - end + # end end format.json do |render| render(json: @datatable) end format.csv do @@ -39,29 +39,29 @@ def show @model_presenter = instantiate_presenter show! do |format| format.html do |render| - begin - render 'show' - rescue + # begin + # render 'show' + # rescue render '/carnival/shared/form/show' - end + # end end end end def new @model_presenter = instantiate_presenter new! do |format| @model = instance_variable_get("@#{controller_name.classify.underscore}") format.html do |render| - begin - render 'new' - rescue + # begin + # render 'new' + # rescue render '/carnival/shared/form/new' - end + # end end end end def edit @@ -77,14 +77,36 @@ end end end def create - create!(:notice => I18n.t("messages.created")) + @model_presenter = instantiate_presenter + create! do |success, failure| + success.html{ redirect_to @model_presenter.model_path(:index), :notice => I18n.t("messages.created") } + failure.html do |render| + @model = instance_variable_get("@#{controller_name.classify.underscore}") + #begin + # render 'edit' + #rescue + render '/carnival/shared/form/new' + #end + end + end end def update - update!(:notice => I18n.t("messages.updated")) + @model_presenter = instantiate_presenter + update! do |success, failure| + success.html{ redirect_to @model_presenter.model_path(:index), :notice => I18n.t("messages.updated") } + failure.html do |render| + @model = instance_variable_get("@#{controller_name.classify.underscore}") + #begin + # render 'edit' + #rescue + render '/carnival/shared/form/edit' + #end + end + end end def render_popup partial @application_popup = partial render 'layouts/shared/render_popup' and return