Defect #1302

Log Time fieldset in IssueController#edit doesn't set default Activity as default

Added by Simone Carletti about 11 years ago. Updated almost 11 years ago.

Status:ClosedStart date:2008-05-26
Priority:NormalDue date:
Assignee:-% Done:


Category:Time tracking
Target version:0.7.2
Resolution:Fixed Affected version:0.7.1


Even if you specified a default activity from /enumerations administration area, the edit issue controller always displays @activities without being aware of any settings.
The select tag always set the first item as the default.

I made a quick search (I can't provide a patch right now, perhaps I'll do when I'll be less busy) and here's some details you can use to debug the problem:


        <div class="splitcontentright">
        <p><%= :activity_id, (@activities.collect {|p| [,]}) %></p>

time_entry instance default :activity_id should be set to @activities default activity id.


    if request.get?
      @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| @issue.custom_values.find_by_custom_field_id( || => x, :customized => @issue) }
      # Update custom fields if user has :edit permission
      if @edit_allowed && params[:custom_fields]
        @custom_values = @project.custom_fields_for_issues(@issue.tracker).collect { |x| => x, :customized => @issue, :value => params["custom_fields"][]) }
        @issue.custom_values = @custom_values

I would probably add here, within the request.get? conditional statement, a default value for new @time_entry values.

fix-time_entry-initialization.diff Magnifier (517 Bytes) Nobuhiro IMAI, 2008-06-13 17:58

Associated revisions

Revision 1461
Added by Jean-Philippe Lang about 11 years ago

Fixed: IssueController#edit doesn't set default Activity as default (#1302).

Revision 1533
Added by Jean-Philippe Lang almost 11 years ago

Fixed: time entries created with the default activity even if a different one is specified (#1302).


#1 Updated by Jean-Philippe Lang about 11 years ago

  • Category changed from Issues to Time tracking
  • Status changed from New to Closed
  • Target version set to 0.7.2
  • Resolution set to Fixed

Fixed in r1461.
I fixed it at model level rather than in the controller. But thanks for pointing out the problem.

#2 Updated by rupert thurner about 11 years ago

  • % Done changed from 0 to 100

#3 Updated by Nobuhiro IMAI almost 11 years ago

After this change, new TimeEntry is always saved with default ACTI, even when
the another activity_id was sent from browser.

This is Rails fanon :-).

>> Foo.belongs_to :bar
>> Bar.has_one :foo
>> foo =
>> = Bar.find(1)
>> foo.bar_id
=> 1
>> foo.bar_id = 2
>> foo.bar_id
=> 2
=> true
>> foo.bar_id
=> 1

The attached patch will fix this problem, I guess.


#4 Updated by Jean-Philippe Lang almost 11 years ago

  • Status changed from Reopened to Closed

Fixed in r1533. Thanks.

Also available in: Atom PDF