1

In my Post model class, I'm trying to debug the following code:

after_create :transcode_video, :if => "is_video? && !Rails.env.development?"

def is_video?
  return false unless post_link
  link_extension = post_link.downcase.split(".").last
  VIDEO_FORMATS.include? link_extension
end

I want to output a debug string to check the value of is_video.

I tried adding

after_create logger.debug "#{is_video}"

and

after_create logger.debug "#{is_video?}"

but get a routing error in each case. I also tried using "puts" instead of logger.

4

1 回答 1

1

我建议以一种方法而不是一行来执行此操作。

就像是:

class MyClass

    after_create :log_is_video

    ...

    private

    def log_is_video
      logger.debug "#{is_video?}"
    end
end
于 2013-11-03T04:25:26.530 回答