Sha256: 2cd6764ea3ac514c3c11c6f4cc9a635f887238577aefc246f27cb130a9132097

Contents?: true

Size: 559 Bytes

Versions: 3

Compression:

Stored size: 559 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(: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
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
bookyt_projects-0.10.0 app/controllers/activities_controller.rb
bookyt_projects-0.9.0 app/controllers/activities_controller.rb
bookyt_projects-0.8.0 app/controllers/activities_controller.rb