instance method append_file_with_newline

Ruby on Rails 7.0.10

Since v6.1.7.10 Private

Available in: v6.1.7.10 v7.0.10 v7.1.6 v7.2.3 v8.0.4 v8.1.2

Signature

append_file_with_newline(path, str, options = {})

Append string to a file with a newline if necessary

Parameters

path req
str req
options opt = {}
Source
# File railties/lib/rails/generators/actions.rb, line 516
        def append_file_with_newline(path, str, options = {})
          gsub_file path, /\n?\z/, options do |match|
            match.end_with?("\n") ? "" : "\n#{str}\n"
          end
        end

Defined in railties/lib/rails/generators/actions.rb line 516 · View on GitHub · Improve this page · Find usages on GitHub

Defined in Rails::Generators::Actions

Type at least 2 characters to search.

↑↓ navigate · open · esc close