lib/generators/cambium/templates/app/controllers/admin_controller.rb in cambium-0.2.2 vs lib/generators/cambium/templates/app/controllers/admin_controller.rb in cambium-0.3.0
- old
+ new
@@ -30,26 +30,28 @@
@item = @model.new(create_params)
if @item.attributes.has_key? 'slug' && !create_params[:slug].blank?
@item.slug = @item.make_slug_unique(create_params[:slug])
end
if @item.save
- redirect_to @routes[:index], :notice => "#{@model.to_s} was successfully created."
+ @routes[:edit] = send("edit_admin_#{model_table_singular}_path", @item)
+ redirect_to @routes[:edit], :notice => "#{@model.to_s} was successfully created."
else
+ @url = @routes[:index]
render :action => "new"
end
end
def update
convert_dates if @item.attributes.has_key?('active_at')
- update_params ||= create_params
if @item.attributes.has_key? 'slug' && !update_params[:slug].blank?
update_params[:slug] = @item.make_slug_unique(update_params[:slug])
end
if @item.update(update_params)
@routes[:edit] = send("edit_admin_#{model_table_singular}_path", @item)
redirect_to @routes[:edit], :notice => "#{@model.to_s} was updated successfully."
else
+ @url = @routes[:show]
render :action => "edit"
end
end
def destroy
@@ -81,8 +83,15 @@
if p[:inactive_date].blank?
p[:inactive_at] = nil
else
p[:inactive_at] = DateTime.parse("#{p[:inactive_date]} #{p[:inactive_time]}")
end
+ end
+
+ def create_params
+ end
+
+ def update_params
+ create_params
end
end