Sha256: 79fd37b2db7500ffed73c6e057d5efe1c99024e39a2bfe8eec7d690d1d676aed

Contents?: true

Size: 644 Bytes

Versions: 2

Compression:

Stored size: 644 Bytes

Contents

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(:date => Date.today)
    end

    # Educated guessing of person
    @activity.person = current_user.person if current_user

    # Educated guessing of project
    @activity.project_id ||= params[:project_id] if params[:project_id]
    @activity.project_id ||= @activity.person.activities.order(:duration_to).last

    new!
  end

  def create
    create! { @activity.project }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
bookyt_projects-0.11.1 app/controllers/activities_controller.rb
bookyt_projects-0.11.0 app/controllers/activities_controller.rb