...have to run a separate process. # You'll also benefit from code reloading. if Rails.env.development? require 'sidekiq/testing' Sidekiq::Testing.inline!
...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...
...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...
...following project: ruby -v ruby 1.8.7 bundler -v Bundler version 1.13.7 gem -v 1.8.30 rails -v Rails 3.2.22.1 Running specs or features resulted in: uninitialized constant Gem::LOADED_SPECS_MUTEX...
...previous settings described in Maximum version of Rubygems and Bundler for Ruby 1.8.7 and Rails 2.3 (even the rails version was rails 3.2 and not 2.3) seems not to work...
...OVER() AS full_count FROM (/* some complicated subquery */) posts LIMIT 20 OFFSET 100; In Rails with will_paginate you might use it like this: posts = scope_complicated_scope.select('posts.*, COUNT(*) OVER() AS...
...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...
...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...
...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...
...For newer Ruby versions, use form_with_development_errors.rb. This monkey patches both form_for and form_with. Rails-XSS is required by default. So if your project doesn't support Rails-XSS...
...want something similar, so we define our own helper object: let :helper do Spec::Rails::Example::HelperExampleGroup::HelperObject.new.tap do |helper| helper.send :extend, LayoutHelper end end it 'should work' helper.title('Hello...
helper.instance_variable_get('@content_for_title').should == 'Hello World' end This applies to Rails 2. Maybe RSpec 2 / Rails 3 are smarter...
...up on the disk check table sizes by disk usage instead. Connect to a Rails database with bin/rails dbconsole -p...
...Note.all.preload(:attachments).ids.size # => 8 Note I created a bug report for this in the Rails project: https://github.com/rails/rails/issues/46455
...or controller) logic. Here is how. Note: this has only been tested on a Rails 2 application. It should work similarly for Rails 3. Put this into your ApplicationController:
Now you can use with_full_urls in views, helpers or controllers and Rails methods like url_for will generate "full" URLs that have a protocol and hostname. You...
Next, configure your application to use that middleware by putting this inside your Rails initializer block (config/environment.rb for Rails 2, config/application.rb for Rails 3): require 'lib/rack/cookie_stripper.rb' config.middleware.use Rack::CookieStripper...
...block where you define replacements (as you already know). This issue applies to both Rails 2 (with rails_xss) as well as Rails 3 applications. Here is a fix to...
...html_safe.gsub(/(f)/) { puts $1; 'b' } f => "boo" Why? This is because of the way rails_xss implements "unsafe" methods: # vendor/plugins/rails_xss/lib/rails_xss/string_ext.rb UNSAFE_STRING_METHODS = [ ..., "gsub",...
for unsafe_method in UNSAFE...
...can remove conditions, order, etc by using the unscope method. It is available on Rails 4+. Examples Consider an exemplary User class as follows. For the examples below, we will...
...scope of any constraints. users.unscoped ^ SELECT "users".* FROM "users" While unscope was introduced with Rails 4, the unscoped method has been around since Rails...
t.column_name, :string t.remove :first_name t.remove :last_name t.rename :cool, :awesome end Rails 2 caveats Rails 2 does not understand the extra options hash but seems to build...
...only created when you rename columns. For other operations such as add and remove Rails 2 will still give you single ALTER statements. More See RobinWu's APIdock comment for...
...This is why we don't use "transactional fixtures" in our Cucumber tests, which Rails by default uses to clean up the database after each test. Instead we use DatabaseCleaner...
...class DynamicStylesheetsController < ApplicationController def show logical_path = RELATIVE_PATH_TO_YOUR_TEMPLATE path = File.join(Rails.root, logical_path) template = Sass::Rails::SassTemplate.new(path) environment = YourApp::Application.assets context = environment.context_class.new(environment, logical_path...
task :script, roles: :app, only: { primary: true } do run "cd #{current_path} && RAILS_ENV=#{rails_env} bundle exec rails runner 'ScriptRunner.go'" end becomes desc 'Run script'
on primary :app do within current_path do with rails_env: fetch(:rails_env, 'production') do execute :bundle, 'exec', "rails runner 'ScriptRunner.go'" end end end end
...you already have stored files in the old structure) Checklist: Using Carrierwave in a Rails project
...page for more information on calculating sizes of databases or tables. Connect to a Rails database with bin/rails dbconsole -p...
Ubuntu 12.04 LTS x64, Ruby 1.8.7, Rails 2.13, PDFKit 0.5.4, Phusion Passenger Apache 2 I ran into this, when I started using passenger to deal with the Single Thread Issue...
...wkhtmltopdf-amd64 /usr/local/bin/wkhtmltopdf sudo chmod +x /usr/local/bin/wkhtmltopdf Tell PDFKit where to find your wkhtmltopdf: Rails::Initializer.run do |config| require "pdfkit" config.middleware.use PDFKit::Middleware PDFKit.configure do |config| config.wkhtmltopdf = '/usr/local/bin/wkhtmltopdf' # <-- the fix...
...uses mocha. This note shows to use RSpec stubs and mocks instead. Rspec 1 / Rails 2 Put the following into your env.rb: require 'spec/stubs/cucumber' Rspec 2 / Rails 3