...et dolore magna aliqua. Mi eget mauris pharetra et ultrices neque." output_mp3_path = Rails.root.join("tts/ipsum.mp3") new Synthesizer(input_text, output_mp3_path).to_mp3 Code require "ruby-openai"

apidock.com

...an instance of its subclasses or superclass. This is useful because some parts of Rails reflect on the class of an instance, e.g. to decide which partial to render:

makandra dev

...for example, you maintain a gem and want to run automated tests against multiple rails versions. When you need to bundle one of your secondary Gemfiles, the solution above is...

...saved to database directly as the the dumped object was not marked dirty, thus rails does not see the need to save it, even if the object is not present...

...So might fix this by adding the following lines to your application.rb: class Application < Rails::Application config.time_zone = 'Berlin' # or whatever your time zone end It seems Date.yesterday uses the...

...add the following tests to test suites: # Make sure to require the previews Dir[Rails.root.join('spec/mailers/previews/*.rb')].each { |file| require(file) } ActionMailer::Preview.all.index_with(&:emails).each do |preview, mails|

...animated GIFs. Resizing them can be a time-consuming task and will block a Rails worker until the image is processed. Save yourself that trouble, and simply tell ImageMagick to...

where html_content can be replaced by one of the following commands: Rails body or response.body Capybara: page.driver.html.content page.body Webrat: Nokogiri::HTML(response.body).content The returned strings can...

makandra dev

...need to configure this if you're using system tests with modern versions of Rails. They do exactly the same

...preprocessed: true end end Preprocess this version for all existing records bundle exec rails runner 'User.find_each { |user| user.avatar.variant(:preview).processed }' Use the new variant and deploy

When you are using PgBouncer with e.g. a Ruby on Rails application which uses different application_names for the PostgreSQL connection (for Puma, Sidekiq, Cronjobs, ...) PgBouncer will set the application...

getbootstrap.com

...use SimpleForm in your project, I would suggest to regenerate the configuration file with rails generate simple_form:install --bootstrap and merge it with your own customizations instead of only...

...partial_double_verification. This might be handy in case you are testing helpers in Rails, where you sometimes rely on methods defined in the application controller (e.g. current_user and...

Webpack is the future. We're using it in our latest Rails applications. For tests, we want to compile assets like for production. For parallel tests, we want to avoid...

...Dir.empty?(public_output_path) end delegate :public_output_path, to: :config private def test? Rails.env.test? end def parallel_tests? test? && !!parallel_tests_number end def parallel_tests_number

...you really want to manage Example One example is used by us in environments::railscomplete::dbcollector: $vhost_types = ['\'Environments::Elixir::Vhost\'', '\'Environments::Rails::Vhost\'', '\'Environments::Php::Vhost\'', '\'Environments::Python::Vhost...

...query("resources {type in ${vhost_types} and parameters.dbbackend = '${dbbackend}'}") $vhosts.each |$vhost| { ensure_resource('environments::railscomplete::db', $vhost['parameters']['dbuser'], { 'password' => $vhost['parameters']['dbpassword'], 'type' => $type, 'extensions' => $vhost['parameters']['dbextensions'], 'schemas...

github.com

Looks simpler than inaction_mailer: gem install mailcatcher mailcatcher Setup Rails to send mails to 127.0.0.1:1025. Usually you want the following config in config/environments/development.rb and maybe in test.rb or...

...config.gem 'chunky_png', :version => '=0.8.0' create config/initializers/compass.rb (or copy from development repo): ^ require 'compass' rails_root = (defined?(Rails) ? Rails.root : RAILS_ROOT).to_s Compass.add_project_configuration(File.join(rails_root, "config...

^ This configuration file works with both the Compass command line tool and within Rails. Require any additional compass plugins here. project_type = :rails project_path = Compass::AppIntegration::Rails.root

If you require your Rails models manually, pay attention to the path you use. Unless you have to, don't do it at all. Background Consider these...

class Foo # something happens here end Now, when your environment is booted, Rails will automatically load your models, like User. In our example, when Foo gets loaded, it...

web.archive.org

Rails 6.1 has a "strict loading" mode that forces the developer to preload any association they plan to use. Associations no longer load lazily. An error is raised when reading...

...for session hashes. Use update instead. Outline Let's assume you're modifying the Rails session. For simplicity, let's also assume your session is empty when you start (same...

...is the ActionController::Session::AbstractStore::SessionHash class (session is of that type in your Rails application, but also in Rack middleware): class SessionHash < Hash # ... def update(hash) load_for_write...

makandra dev

...on to the console IRB. console command: Ctrl + C now properly exits a local Rails console rspec and cucumber commands: Run specs even if the automatic chromedriver update fails

...our output will be more verbose than when we only need support modern browsers. Rails 5.1+ projects often use Webpacker to preconfigure the Webpack pipeline for us. The default configuration...

...Follow the instructions in the README. Most likely you want: to add the Ruby, Rails and RSpec cops to include the unit test 2. Report all existing offenses and exclude...

github.com

...TILs on many topics that might be interesting for most of us. (e.g. Ruby, Rails, Git, Unix..) Ruby Here is an excerpt of all the Ruby TILs that were new...