Skip to content

Instantly share code, notes, and snippets.

@brandon-beacher
Created April 20, 2011 22:41
Show Gist options
  • Save brandon-beacher/933253 to your computer and use it in GitHub Desktop.
Save brandon-beacher/933253 to your computer and use it in GitHub Desktop.
def create
@article = @publication.news.build params[:article]
@article.person = current_person
if @article.save
flash[:notice] = "Article was saved"
respond_to do |format|
format.html { redirect_to management_article_path(@parish, @publication, @article) }
format.xml { render :show, :status => :created, :location => management_article_path(@parish, @publication, @article, :format => :xml) }
end
else
respond_to do |format|
format.html { render :action => "new" }
format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
end
end
end
def update
@article = @publication.news.find params[:id]
@article.attributes = params[:article]
if @article.save
flash[:notice] = "Article was saved"
respond_to do |format|
format.html { redirect_to management_article_path(@parish, @publication, @article) }
format.xml { head :ok }
end
else
respond_to do |format|
format.html { render :action => "edit" }
format.xml { render :xml => @article.errors, :status => :unprocessable_entity }
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment