13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/blog_basic/blog_comments_controller.rb', line 13
def create
@blog_comment = @blog_post..new(params[:blog_comment])
@blog_comment.user_id = current_user.id if current_user
@blog_comment.request = request
respond_to do |format|
if @blog_comment.save
flash[:notice] = 'Your comments has been posted.'
format.html { redirect_to(@blog_post) }
format.xml { render :xml => @blog_comment, :status => :created, :location => @blog_comment }
else
format.html do
@blog_comments = @blog_post..paginate(:page => params[:page], :order => 'created_at DESC')
render :template => '../views/blog_posts/show.html.erb'
end
format.xml { render :xml => @blog_comment.errors, :status => :unprocessable_entity }
end
end
end
|