Created
January 11, 2012 22:05
-
-
Save eileencodes/1597034 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Admin::PostsController < Admin::AdminController | |
#only showing the update method | |
def update | |
@post = Post.find(params[:id]) | |
if @post.valid? | |
add_author_to_post | |
save_or_remove_post_categorization | |
end | |
respond_to do |format| | |
if @post.update_attributes(params[:post]) | |
format.html { redirect_to [ :edit_admin_post ], :notice => 'Post was successfully updated.' } | |
else | |
format.html { render :action => "edit" } | |
end | |
end | |
end | |
#method created for adding user to posts table | |
def add_author_to_post | |
@user = User.find_by_id(session[:user_id]) | |
@user.posts << @post | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment