lib/generators/templates/app/controllers/base.rb in beautiful_scaffold-0.1.3 vs lib/generators/templates/app/controllers/base.rb in beautiful_scaffold-0.1.4
- old
+ new
@@ -97,13 +97,25 @@
def create
@<%= model %> = <%= model_camelize %>.create(params[:<%= model %>])
respond_to do |format|
if @<%= model %>.save
- format.html { redirect_to <%= namespace_for_route %><%= singular_table_name %>_path(@<%= model %>), :notice => t(:create_success, :model => "<%= model %>") }
+ 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 %>")
+ end
+ }
format.json { render :json => @<%= model %>, :status => :created, :location => @<%= model %> }
else
- format.html { render :action => "new" }
+ format.html {
+ if params[:mass_inserting] then
+ redirect_to <%= namespace_for_route %><%= model_pluralize %>_path(:mass_inserting => true), :error => t(:error, "Error")
+ else
+ render :action => "new"
+ end
+ }
format.json { render :json => @<%= model %>.errors, :status => :unprocessable_entity }
end
end
end