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

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

...one (pnpm add, pnpm install), the lock file is pnpm-lock.yaml. See the card Our Rails stack for the bigger picture...

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

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

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

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

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

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

...shell commands inside other bundles. Example outline Consider this setup: my_project/Gemfile # says: gem 'rails', '~> 3.0.0' my_project/foo/Gemfile # says: gem 'rails', '~> 3.2.0' And, just to confirm this, these are the...

...installed Rails versions for each of the bundles: ~/my_project$ bundle show rails .../gems/rails-3.0.20 ~/my_project$ cd foo && bundle show rails .../gems/rails-3.2.13 Now you will usually just use bundle exec to run...

...this on the top of your config/schedule.rb: job_type :runner, "cd :path && bundle exec rails runner -e :environment ':task' :output...

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

...deployed to the servers. The gems of these groups might not be loaded by rails, however, the deployment process will take longer as the gems will be downloaded and installed...

...a month or a year. Next, start your application server for HTTPS. For a Rails application with Puma: bin/rails server -b 'ssl://0.0.0.0:3000?key=development.key&cert=development.crt'

...many more processes than just your tests while your test suite is running: The Rails server booted by each test process (in a separate process) The Chrome browser started by...

...is good programming practice to Don't Repeat Yourself (or DRY). In Ruby on Rails we keep our code DRY by sharing behavior by using inheritance, modules, traits or partials...

...bar']) => /tmp/foo20220912-14561-3g93n1bar You can choose a different base directory than Dir.tmpdir e.g. Dir.mktmpdir('foo', Rails.root.join('tmp')) => /home/user/rails_example/tmp/foo20220912-14561-pyr8qd. This might be necessary when your tests are running on CI. For this...

...something with a temporary directory' do # ... end Option 4: Without Dir.mktmpdir Use something like "#{Rails.env}#{ENV['TEST_ENV_NUMBER']}" in you directory path when using Dir.mkdir. Further reading:

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

...set of boolean flags. You can implement a state machine in plain Ruby and Rails: a state column, transition methods that only allow valid transitions, and callbacks on transition.

...can implement the same with a gem like rails_state_machine and explain what the gem adds over the hand-written version. You can make validations depend on the record...

...Transactions and database setup, and Drivers (rack_test vs. Selenium) 📄 Feature specs in rspec-rails — how a feature spec is set up, and how js: true switches an example to...

Use gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.2.x-lts' # for Rails 2.x gem 'mysql2', git: 'https://github.com/makandra/mysql2', branch: '0.3.x-lts' # for Rails...