<commit_before>class RepliesController < ApplicationController
  before_filter :require_logined, :require_user_not_banned
  respond_to :js, :only => [:create]
  
  def new
    set_page_title I18n.t 'replies.new.new_reply'
    @topic = Topic.find params[:topic_id]
    if @topic.closed?
      render_422
    else
      @reply = Reply.new
      @reply.topic_id = @topic.id
    end
  end

  def create
    @topic = Topic.find params[:reply][:topic_id]
    if @topic.closed?
      render_422
    else
      @reply = @topic.replies.new params[:reply]
      @reply.user = current_user
      @reply.save
      respond_with @reply do |format|
        format.html do
          if @reply.valid?
            redirect_to topic_url_with_last_anchor(@topic)
          else
            set_page_title I18n.t 'replies.new.new_reply'
            render :new, :topic_id => @topic.id
          end
        end
        format.js { render :layout => false }
      end
    end
  end

  def edit
    set_page_title I18n.t 'replies.edit.edit_reply'
    @reply = current_user.replies.find params[:id]
    @topic = @reply.topic
  end

  def update
    @reply = current_user.replies.find params[:id]
    @topic = @reply.topic
    if @reply.update_attributes params[:reply]
      redirect_to params[:return_to].blank? ? @topic : "#{params[:return_to]}##{@reply.id}"
    else<commit_msg>fix update repliy redirect path.<commit_after>class RepliesController < ApplicationController
  before_filter :require_logined, :require_user_not_banned
  respond_to :js, :only => [:create]
  
  def new
    set_page_title I18n.t 'replies.new.new_reply'
    @topic = Topic.find params[:topic_id]
    if @topic.closed?
      render_422
    else
      @reply = Reply.new
      @reply.topic_id = @topic.id
    end
  end

  def create
    @topic = Topic.find params[:reply][:topic_id]
    if @topic.closed?
      render_422
    else
      @reply = @topic.replies.new params[:reply]
      @reply.user = current_user
      @reply.save
      respond_with @reply do |format|
        format.html do
          if @reply.valid?
            redirect_to topic_url_with_last_anchor(@topic)
          else
            set_page_title I18n.t 'replies.new.new_reply'
            render :new, :topic_id => @topic.id
          end
        end
        format.js { render :layout => false }
      end
    end
  end

  def edit
    set_page_title I18n.t 'replies.edit.edit_reply'
    @reply = current_user.replies.find params[:id]
    @topic = @reply.topic
  end

  def update
    @reply = current_user.replies.find params[:id]
    @topic = @reply.topic
    if @reply.update_attributes params[:reply]
      redirect_to params[:return_to].blank? ? @topic : "#{params[:return_to]}#reply-#{@reply.id}"
    else
{'fraction_non_alphanumeric': 0.10580080262677855, 'fraction_numerical': 0.008755928493250638, 'mean_word_length': 2.5380645161290323, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7572674', 'n_tokens_mistral': 926, 'n_tokens_neox': 918, 'n_words': 195}