ActiveRecord::Base.transaction do
ActiveRecord::Base.connection.execute('LOCK scheduling_informations IN ACCESS EXCLUSIVE MODE')
SchedulingInformation.delete_all
end
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "csv" | |
| class CsvFileHandler | |
| # Reads specific columns or all columns from a CSV file. | |
| # column_indices is an array of integers representing the column numbers to read. | |
| # If column_indices is empty or not provided, all columns are read. | |
| BATCH_SIZE = 1000 | |
| def self.read_from_csv(file_path, column_indices = [], separator = ",") | |
| data = [] | |
| CSV.foreach(file_path, headers: true, header_converters: :symbol, col_sep: separator) do |row| |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This module must be included in controllers | |
| # to get the functionality of the methods. | |
| # Remember to call `super` in overridden methods. | |
| # In views, the object `@resource` is available. | |
| module DryController | |
| extend ActiveSupport::Concern | |
| included do | |
| before_action :set_resource_class | |
| before_action :set_index, only: :index |
heroku logs --app app-name --tailheroku logs --app app-name -n 1500(for the last 1500 lines)heroku logs --app app-name --tail --ps worker(worker logs)
heroku pg:backups:capture -a app-name(create the dump)heroku pg:backups:download -a app-name(download the dump)
Cheat Sheets are greate but they are not a substitute for learning the framework and reading the documentation as we most certainly have not covered every potential example here. Please refer to the Rails Command Line Docs for more information.
You can get all of this information on the command line.
rails generate with no generator name will output a list of all available generators and some information about global options.
rails generate GENERATOR --help will list the options that can be passed to the specified generator.
This list is based on aliases_spec.rb.
You can see also Module: RSpec::Matchers API.
| matcher | aliased to | description |
|---|---|---|
| a_truthy_value | be_truthy | a truthy value |
| a_falsey_value | be_falsey | a falsey value |
| be_falsy | be_falsey | be falsy |
| a_falsy_value | be_falsey | a falsy value |