instance method
lib
Ruby on Rails 6.1.7.10
Since v3.0.20Signature
lib(filename, data = nil)
Create a new file in the lib/ directory. Code can be specified in a block or a data string can be given.
lib("crypto.rb") do "crypted_special_value = '#{rand}--#{Time.now}--#{rand(1337)}--'" end lib("foreign.rb", "# Foreign code is fun")
Parameters
-
filenamereq -
dataopt = nil
Source
# File railties/lib/rails/generators/actions.rb, line 175
def lib(filename, data = nil)
log :lib, filename
data ||= yield if block_given?
create_file("lib/#{filename}", optimize_indentation(data), verbose: false)
end
Defined in railties/lib/rails/generators/actions.rb line 175
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Rails::Generators::Actions