...command line flag when opening an IRB: irb --nomultiline This also works on modern Rails when using rails console like so: rails console -- --nomultiline Option 2: Disable by default

...excludes quote characters so you can easily paste the secret into a Ruby string Rails can also generate secrets that can be used for secret_key_base: $ bin/rails secret 5693040b90b1b09d0a73364d950f15e3a9604403c8e81c6e5bb8b51d0981ef3bbde15a52bf5df41ac4974675bb8e31d69d03490dc11abd1086c873783d1be607

github.com

...ids on an ActiveRecord scope to pluck all the ids of the relation: # Modern Rails User.where("users.name LIKE 'Foo Bar'").ids # Rails 3.2+ equivalent User.where("users.name LIKE 'Foo Bar'").pluck...

# Edge rider equivalent for Rails 2+ User.where("users.name LIKE 'Foo Bar'").collect_ids

Don't insert table rows in a Rails database migration. This will break tests that expect that database to be empty and cause you all sorts of pain.

...cloned project. The reason is your environment.rb which is loaded for Raketasks and calls Rails.application.initialize! which in turn may/will evaluate classes. If one of those classes is tries to access...

...if you don't know which one handled the request you are looking for. Rails application logs usually live in /var/www/ /shared/log. Web server logs usually live in /var/www/ /log...

...multiple servers at the same time With a custom Capistrano task: CMD='zgrep -P "..." RAILS_ROOT/log/production.log' bundle exec cap production app:run_cmd See Capistrano 3: Running a command on...

# ActiveRecord 3.2+ was activated end Detect if a gem has been required Rails will automatically require all the gems in your Gemfile, unless you pass the require: false...

...option. When working on non-Rails project (such as a gem), nothing is required automatically. To detect if a gem has been required, use defined? on one of the modules...

expect(time1).to eq(time2) end Note for users of #end_of_day Rails extends Time with a method #end_of_day which returns the latest possible Time on...

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

From Exploring ES6: Module imports are hoisted (internally moved to the beginning of the current scope). Therefore, it doesn’t...

...use a light terminal theme Improving Diffs for Ruby, RSpec and Cucumber files See Rails developers: Have better context in Git diffs. This will correctly identify the beginning of a...

...MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques can be implemented in any language or framework. We will be using...

...ein User ungefiltertes HTML in die Webseite einfügen kann. Danke für den interessanten Beitrag! alert('you have been hacked') Rails löst das Problem weitgehend, aber Programmierfehler weiter möglich manchmal Sicherheitslücken in Gems oder Rails

background-color: blue; } = javascript_tag nonce: true do :plain window.addEventListener('load', () => { ... }); CSP mit Rails Demo Konfiguration via config/initializer/content_security_policy.rb Überschreiben in einzelnen Controllern Nonce-Support für javascript_tag

...version "3.4.0" resolved "https://registry.yarnpkg.com/jquery/-/jquery-3.4.0.tgz#8de513fa0fa4b2c7d2e48a530e26f0596936efdf" integrity sha512-ggRCXln9zEqv6OqAGXFEcshF5dSBvCkzj6Gm2gzuR5fWawaX8t7cxKVkkygKODrDAzKdoYw3l/e3pm3vlT4IbQ== package.json { "dependencies": { "@rails/webpacker": "4.x", "bootstrap-datepicker": "1.8.0", # the package says it needs "jquery": ">=1.7.1 <4.0.0" as a dependency

...node_modules/jquery node_modules/bootstrap-datepicker/node_modules/jquery Actual issue Within the Rails Webpacker config we now provide a jQuery object to boostrap-datepicker: config/webpack/environment.js environment.plugins.prepend( 'Provide', new webpack.ProvidePlugin({ $: 'jquery', jQuery: 'jquery', 'window.jQuery': 'jquery...

When I sign in as "carcar79" Patch to make it work for Rails 2 For Rails 2, the last line of find_by_anything needs to be changed...

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

This card shows how to get a Ruby method touch_device? for your Rails views and a method TouchDevice.isPresent() for your Javascripts. Note that we are detecting touch devices...

...pass your string or stream directly. >> Attachment.create!(file: FileIO.new(contents, 'document.pdf')) => # When using zeitwerk (Rails 6) you might also need to add an inflection in order to make autoloading work...

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

When your JavaScript bundle is so massive that you cannot load it all up front, I would recommend to load...

...when your application uses time zones. Background A time-zoned Time attribute on a Rails record is converted to UTC using to_s(:db) to be stored, and converted back...

...delay of ~1 minute. Note: This setup does not work, when you use the Rails driven_by method with a binary preloading for parallel tests. CI Optionally you can use...

...used to match rows without knowing a secret token: Potential Query Manipulation with Common Rails Practises CVE-2013-3211 MySQL madness and Rails

...This could be your (very careless) controller method: def generated send_file File.join(Rails.root, 'shared', 'invoices', params[:number]) end This allows your users not only to access those files but...

...directory of the files as the first parameter, like so: send_file_inside File.join(Rails.root, 'shared', 'invoices'), params[:number] Do not use only Rails.root -- this would allow access to config/environment.rb...