["\n\n
\n \n\nRails Execution is an Engine to manage the Rails scripts for migration, cleanup, and fixing the bad data without deployment.
\n\n\n
Add the following line to your Gemfile:
\n\ngem 'rails_execution'\n
\n\nThen run bundle install
You need to run the generator:
\n\n $ rails g rails_execution:install\n
\n\nAnd you can change the config in config/initializers/rails_execution.rb
Default is Solo Mode
, without the Reviewing process.
The first step is to disable the Solo Mode
config.solo_mode = false\n
\n\nAnd then uncomment the configures of the owner
and reviewers
config.owner_model = 'User'\n config.owner_method = :current_user\n config.owner_name_method = :name\n config.owner_avatar = ->(owner) { owner.avatar.url }\n\n config.reviewers = -> do\n User.where(is_admin: true).map do |user|\n {\n name: user.name,\n id: user.id,\n type: 'User',\n avatar_url: user.avatar.url,\n }\n end\n end\n
\n\nRun the generator to add the FileUploader and FileReader
\n\n $ rails g rails_execution:file_upload\n
\n\nAnd then uncomment the file upload
\n\n config.file_upload = true\n config.file_uploader = ::RailsExecution::FileUploader\n config.file_reader = ::RailsExecution::FileReader\n
\n\nTo limit the File types. Default: .png
, .gif
, .jpg
, .jpeg
, .pdf
, .csv
\nYou can modify the limitation like this
config.acceptable_file_types = {\n '.jpeg': 'image/jpeg',\n '.pdf': 'application/pdf',\n '.csv': ['text/csv', 'text/plain'],\n }\n
\n\nFor example with Pundit authorization.
\n\n config.task_creatable = lambda do |user|\n YourPolicy.new(user).creatable?\n end\n config.task_editable = lambda do |task, user|\n YourPolicy.new(user, task).editable?\n end\n config.task_closable = lambda do |task, user|\n YourPolicy.new(user, task).closable?\n end\n config.task_approvable = lambda do |task, user|\n YourPolicy.new(user, task).approvable?\n end\n config.task_executable = lambda do |task, user|\n YourPolicy.new(user, task).executable?\n end\n
\n\nTo storage the logfile
\n\n config.logging = lambda do |file, task|\n LoggerModel.create!(task: task, file: file)\n end\n
\n\nAnd list the logfiles on Task page
\n\n config.logging_files = lambda do |task|\n LoggerModel.where(task: task).map do |log|\n log.file.expiring_url(30.minutes.to_i)\n end\n end\n
\n\nTo change the Per page of the tasks list.\nDefault value: 20
config.per_page = 10\n
\n