Skip to content

Commit

Permalink
Topic is already gathered by find_topic, we only care about the last …
Browse files Browse the repository at this point in the history
…10 posts when the save fails
  • Loading branch information
radar committed Oct 23, 2009
1 parent 45693b6 commit b11bd40
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions app/controllers/posts_controller.rb
Expand Up @@ -17,17 +17,14 @@ def new
end

def create
@topic = Topic.find(params[:topic_id], :include => :posts)

# The last 10 posts for this topic
@posts = @topic.posts.find(:all, :order => "id DESC", :limit => 10)

@post = @topic.posts.build(params[:post].merge!(:user => current_user, :ip => @ip))

if @post.save
flash[:notice] = t(:created, :thing => "post")
go_directly_to_post
else
# The last 10 posts for this topic
@posts = @topic.last_10_posts
@quoting_post = Post.find(params[:quote]) unless params[:quote].blank?
flash.now[:notice] = t(:not_created, :thing => "post")
render :action => "new"
Expand Down

0 comments on commit b11bd40

Please sign in to comment.