stackoverflow.com

...method's source code If your Gemfile comes with method_source (a dependency of Rails 7+), you can can inspect the source code directly using the Method#source method:

...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...

linux.die.net

...also use Cookies with cURL. For easily making HTTP requests in an IRB or Rails console, take a look at the HTTP gem. If you prefer a GUI, take a...

...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...

evilmartians.com

...building it yourself Also see the chapter "Owning your Stack" in the book Growing Rails Applications in Practice. Services Open-Source Maturity & Maintenance Certification Rubygems

...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...

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

haml.info

%span Reference %pre ~ content Reference Hello World Textareas In some versions of Haml + Rails, this may also be an issue for textarea elements. Fix it similarly: # Indented description

...so that a tcp connection is used instead of a socket connection. Configure rails application to use the database development: adapter: mysql2 database: projectname_development encoding: utf8mb4 collation: utf8mb4_unicode...

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...

...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|

github.com

...mocked with Timecop. To integrate those two, we include and activate timemachine.js in our Rails layout whenever we see that Timecop is mocking the time: - if defined?(Timecop) && Timecop.top_stack...

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...

...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...

...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

leomayleomay.github.io

Your after_commit callbacks will not know about changes, as Rails discards them when committing. The linked article shows a clever trick to work around that: It uses an after...

...commit, and not after_save. Enqueueing a Sidekiq job is just one of them. Rails 5+ You can use saved_change_to_attribute? and previous_changes[:attribute] in after_commit...

...object-oriented scripting language Ruby rubymine 2018.3.2 jetbrains✓ classic The Most Intelligent Ruby and Rails IDE ... Switch channel and install most recent version: $ sudo snap refresh rubymine --channel=2018.2/stable...

...image running the headless Chrome (e.g. chrome:4444) The integration test is testing a Rails application (but it could be any other application, too) Start your integration test docker container...

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...

stackoverflow.com

...Stefan', color: 'red'} ] names = users.collect do |user| user[:name] end If you're using Rails 5+, this example is covered by Enumerable#pluck (users.pluck(:name)). But with a little extension...

...up on the disk check table sizes by disk usage instead. Connect to a Rails database with bin/rails dbconsole -p...

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...