<commit_before>class ActivitiesController < AuthorizedController
  belongs_to :project

  def new
    # Allow callers specifying defaults
    if params[:activity]
      @activity = Activity.new(params[:activity])
    else
      @activity = Activity.new
    end

    # Nested resources support
    @activity.project_id ||= params[:project_id] if params[:project_id]
    # Educated guessing of defaults
    @activity.person = current_user.person if current_user

    @project ||= Project.new
    
    new!
  end

  def create
    @activity = Activity.create(params[:activity])
    @project = @activity.project

    create! { project_path(@project) }
  end

  def index
    redirect_to :projects
  end
end<commit_msg>Set associated model project as optional.<commit_after>class ActivitiesController < AuthorizedController
  belongs_to :project, :optional => true

  def new
    # Allow callers specifying defaults
    if params[:activity]
      @activity = Activity.new(params[:activity])
    else
      @activity = Activity.new(:when => Date.today)
    end

    # Nested resources support
    @activity.project_id ||= params[:project_id] if params[:project_id]
    # Educated guessing of defaults
    @activity.person = current_user.person if current_user

    new!
  end

  def create
    create! { @activity.project }
  end

  def index
    redirect_to :projects
  end
end
{'fraction_non_alphanumeric': 0.08527696793002916, 'fraction_numerical': 0.0, 'mean_word_length': 3.3449367088607596, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '4377043', 'n_tokens_mistral': 395, 'n_tokens_neox': 378, 'n_words': 107}