Sha256: e824c5b3bbabb1fb90cfef9c1d2f9aa4aba6865360ae1f1948c5596629a1e1b4

Contents?: true

Size: 706 Bytes

Versions: 1

Compression:

Stored size: 706 Bytes

Contents

class ActivitiesController < AuthorizedController
  belongs_to :project, :optional => true
  belongs_to :person, :optional => true

  has_scope :by_date

  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

1 entries across 1 versions & 1 rubygems

Version Path
bookyt_projects-0.12.0 app/controllers/activities_controller.rb