lib/generators/templates/app/controllers/base.rb in beautiful_scaffold-0.3.0.rc6 vs lib/generators/templates/app/controllers/base.rb in beautiful_scaffold-0.3.1

- old
+ new

@@ -33,15 +33,11 @@ :per_page => 20 ).all respond_to do |format| format.html{ - if request.headers['X-PJAX'] - render :layout => false - else - render - end + render } format.json{ render :json => @<%= model %>_scope.all } format.csv{ @@ -65,30 +61,22 @@ end def show respond_to do |format| format.html{ - if request.headers['X-PJAX'] - render :layout => false - else - render - end + render } format.json { render :json => @<%= model %> } end end def new @<%= model %> = <%= model_camelize %>.new respond_to do |format| format.html{ - if request.headers['X-PJAX'] - render :layout => false - else - render - end + render } format.json { render :json => @<%= model %> } end end @@ -103,18 +91,18 @@ if @<%= model %>.save format.html { if params[:mass_inserting] then redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true) else - redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:create_success, :model => "<%= model %>") + redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :flash => { :notice => t(:create_success, :model => "<%= model %>") } end } format.json { render :json => @<%= model %>, :status => :created, :location => @<%= model %> } else format.html { if params[:mass_inserting] then - redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true), :error => t(:error, "Error") + redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true), :flash => { :error => t(:error, "Error") } else render :action => "new" end } format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity } @@ -124,10 +112,10 @@ def update respond_to do |format| if @<%= model %>.update_attributes(params_for_model) - format.html { redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:update_success, :model => "<%= model %>") } + format.html { redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :flash => { :notice => t(:update_success, :model => "<%= model %>") }} format.json { head :ok } else format.html { render :action => "edit" } format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity } end