diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -69,14 +69,24 @@ if @announcement.update_attributes(params[:announcement]) flash[:notice] = 'Announcement was successfully updated.' format.html { redirect_to(@announcement) } + format.js {} format.xml { head :ok } else format.html { render :action => "edit" } + format.js {} format.xml { render :xml => @announcement.errors, :status => :unprocessable_entity } end end end + def toggle + @announcement = Announcement.find(params[:id]) + @announcement.update_attributes( published: params[:published] == 1) + respond_to do |format| + format.js {} + end + end + # DELETE /announcements/1 # DELETE /announcements/1.xml def destroy