What are best practices of creating database importer in Rails?
Some notes:


As usual, I'd recommend a more functional approach. It's not a theoretical issue, functional code is more concise, more clear. When I see @k = [] I get the shakes thinking that this variable can (and will) be modified just everywhere in the class (an instance variable is just a nasty global variable -for the scope a class, granted- with a pretty name).
Also related to FP, your code is hard to abstract because it's written with procedures instead of functions: they don't take values (as arguments) and return values, everything works by side-effects through instance variables. No referential transparency, no idempotence...
Don't create so many individual constants, group them in hashes.
File.open 'data/PAC_APO.GES', 'r'. Hardcoded files in classes? mmmm.
96 * 1000 + 760 + 9. Magic number, define it as a constant so it has a name.


Answering your particular question about how to avoid repeating code for those 3 methods: whatever is different put it as arguments. If some value depends on something the caller cannot know yet about (the code under when I, U, D), then use an argument block as callback. So it might be written:

def extract_to_database(collection)
  add       = true
  tmp       = []
  type      = K

  collection.each_with_index do |line, i|
    break if (i &gt; 96 * 1000 + 760 + 9)

    _type    = line.strip
    _changed = TYPES.include? _type

    if _changed &amp;&amp; i &gt; 0
      case type
      when K then @k &lt;&lt; tmp
      when F then @f &lt;&lt; tmp
      when FB then @f &lt;&lt; tmp
      when I, U, D
        yield(tmp)
      end

      tmp  = []
      type = _type
    end

    tmp &lt;&lt; clean(line)
  end
end


Note that I kept your old imperative code (a functional approach would require rewriting the full class), but at least is now DRYed. I'd strongly encourage to try the functional paradigm, it's hard at first but it pays off on the long run. My article on this matter.