format.json { render json: @item.to_json(@my_model_class.show_json_opt) }
end
+ def show_json_format_for_root format
+ format.json { render json: @item.to_json(@my_model_class.show_json_opt_for_root) }
+ end
+
def set_new
set_model
@item = @my_model_class.new
render_form
end
- def created_html_format format
+ 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 @item
+ redirect_to (redirect_url ? redirect_url : @item)
}
end
}
end
- def render_create
+ def render_create redirect_url = nil
if @item.save
respond_to do |format|
- created_html_format format
+ created_html_format format, redirect_url
created_json_format format
end
else
end
end
- def updated_html_format format
+ 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 @item
+ redirect_to (redirect_url ? redirect_url : @item)
}
end
}
end
- def render_update
+ def render_update redirect_url = nil
if @item.save
respond_to do |format|
- updated_html_format format
+ updated_html_format format, redirect_url
updated_json_format format
end
else