Sha256: 3af0dd1fb6f73234c9135cfef8d677df25c0f824867e6cf13fb85d99e3da3184

Contents?: true

Size: 699 Bytes

Versions: 12

Compression:

Stored size: 699 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(:date).last

    new!
  end

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

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
bookyt_projects-0.19.6 app/controllers/activities_controller.rb
bookyt_projects-0.19.5 app/controllers/activities_controller.rb
bookyt_projects-0.19.4 app/controllers/activities_controller.rb
bookyt_projects-0.19.3 app/controllers/activities_controller.rb
bookyt_projects-0.19.2 app/controllers/activities_controller.rb
bookyt_projects-0.19.1 app/controllers/activities_controller.rb
bookyt_projects-0.19.0 app/controllers/activities_controller.rb
bookyt_projects-0.18.3 app/controllers/activities_controller.rb
bookyt_projects-0.18.2 app/controllers/activities_controller.rb
bookyt_projects-0.18.1 app/controllers/activities_controller.rb
bookyt_projects-0.14.0 app/controllers/activities_controller.rb
bookyt_projects-0.13.0 app/controllers/activities_controller.rb