app/controllers/your_data_controller.rb
def create_activity
    # Convert duration of activity to unified format
    params[:activity]['minutes'] = Activity.convert_duration(params[:activity]['minutes'])

    @activity = Activity.new(params[:activity])
    @activity.user = @current_user
    @projects = Project.find_active

    # Warn user if he already has activity on the same project/date pair
    if @current_user.activities.find_by_date_and_project_id(@activity.date, @activity.project_id)
      flash[:warning] = "You already have activity on selected project and date. Make sure that you didn't make a mistake."
    end
    if @activity.save
      flash[:notice] = 'Activity has been successfully created'
      redirect_to :action => 'activities_list'
    else
      render :action => 'new_activity'
    end
  end
#
# Creates new activity based on information passed in form
#

Creates new activity based on information passed in form
Creates new activity based on information passed in form
def create_activity
    params[:activity]['minutes'] = Activity.convert_duration(params[:activity]['minutes'])
    @activity = Activity.new(params[:activity])
    @activity.user = @current_user
    @projects = Project.find_active
    if @current_user.activities.find_by_date_and_project_id(@activity.date, @activity.project_id)
      flash[:warning] = "You already have activity on selected project and date. Make sure that you didn't make a mistake."
    end
    if @activity.save
      flash[:notice] = 'Activity has been successfully created'
      redirect_to :action => 'activities_list'
    else
      render :action => 'new_activity'
    end
  end
def create_activity params [ :activity ] [ 'minutes' ] = Activity . convert_duration ( params [ :activity ] [ 'minutes' ] ) @activity = Activity . new ( params [ :activity ] ) @activity . user = @current_user @projects = Project . find_active if @current_user . activities . find_by_date_and_project_id ( @activity . date , @activity . project_id ) flash [ :warning ] = "You already have activity on selected project and date. Make sure that you didn't make a mistake." end if @activity . save flash [ :notice ] = 'Activity has been successfully created' redirect_to :action => 'activities_list' else render :action => 'new_activity' end end
Creates new activity based on information passed in form
Creates new activity based on information passed in form
# Convert duration of activity to unified format
 # Warn user if he already has activity on the same project/date pair
