2017-02-20 11 views
0

ミーティングプラグインを更新しました。このプラグインでは、会議を更新するときに会議の履歴が更新されません。 件名を変更して件名を変更しても件名は更新されますが、問題のような履歴は更新されません。ジャーナルを使ってRedmineプラグインの履歴アイテムを追加するには

Redmineのの私の構成は、私が

def update_meeting_from_params 
    @edit_allowed = User.current.allowed_to?(:edit_meetings, @project) 
    @time_entry = TimeEntry.new(:meeting => @meeting, :project => @meeting.project) 
    @time_entry.attributes = params[:time_entry] 

    @meeting.init_journal(User.current) 

    meeting_attributes = params[:meeting] 
    @meeting.safe_attributes = meeting_attributes 
    end 

私のモデルクラス

def init_journal(user, notes = "") 
    @current_journal ||= Journal.new(:journalized => self, :user => user, :notes => notes, :notify => false) 

    if new_record? 
     @current_journal.notify = false 
    else 
     @attributes_before_change = attributes.dup 
    end 
    @current_journal 
    end 

    def last_journal_id 
    if new_record? 
     nil 
    else 
     journals.maximum(:id) 
    end 
    end 

    # Returns a scope for journals that have an id greater than journal_id 
    def journals_after(journal_id) 
    scope = journals.reorder("#{Journal.table_name}.id ASC") 
    if journal_id.present? 
     scope = scope.where("#{Journal.table_name}.id > ?", journal_id.to_i) 
    end 
    scope 
    end 

    def create_journal 
    if @current_journal 
     # attributes changes 
     if @attributes_before_change 
     (Meeting.column_names - %w(id created_at updated_at)).each {|c| 
      before = @attributes_before_change[c] 
      after = send(c) 
      next if before == after || (before.blank? && after.blank?) 
      @current_journal.details << JournalDetail.new(:property => 'attr', 
                 :prop_key => c, 
                 :old_value => before, 
                 :value => after) 
     } 
     end 
     @current_journal.save 
     # reset current journal 
     init_journal @current_journal.user, @current_journal.notes 
    end 
    end 

用とコントローラクラスのfollowing->

を行っている

Environment: 
    Redmine version    3.3.1.stable 
    Ruby version     2.1.5-p273 (2014-11-13) [x86_64-linux] 
    Rails version     4.2.7.1 
    Environment     development 
    Database adapter    Mysql2 

を以下のようです私は次のエラーに遭う。 http://prntscr.com/eb257g

+0

? –

+0

は最新バージョンです。 質問を自分の環境で更新します。 –

+0

そして、どのミーティングのプラグインですか? –

答えて

1

あなたのジャーナルオブジェクト(会議)がjournalized_attribute_names

というメソッドを持っている必要があり、私を助けてください、あなたのモデル(meeting.rb)に追加してください:どのRedmineのバージョン

# Returns the names of attributes that are journalized when updating the meeting 
def journalized_attribute_names 
    names = Meeting.column_names - %w(id created_on updated_on) 
    names 
end 
+0

はい、動作しますが、このような別のエラーが出ます。 #

+0

http://prntscr.com/ebhaun –

+0

のための未定義のメソッド 'custom_field_values '" Issue "モデルを見て、これらのメソッドがどのように実装されているかを見てください。次に、それらをカスタムモデル(会議)に適応させて追加するだけです。 – Nanego

関連する問題