...app/models/test.rb index eg3c1k1..843c0a2 31143 --- app/models/test.rb +++ app/models/test.rb @@ -19,6 +19,10 @@ module RoutingFilter path = Rails.root / 'app' + if true + + end + return path (1/1) Discard this hunk from worktree [y,n,q...
...your application perform with lots of data? Generate many records per table. Watch the Rails logs and query_diet to find areas of improvement. Reduce N+1 queries, preload associations...
Running rails server will start a local server that you can access via http://localhost:3000. When you are working on multiple web apps, they will likely set cookies with...
...define it in a single place so switching it out will be easy. Modern rails versions will block hosts other than localhost by default. Therefore create an entry in config/environments/development.rb...
...creation if you're on a POSIX system. If you are using Ruby on Rails, a use case / implementation might look like Rails 3: Sending tempfiles for download.
Rails 6 includes a WYSIWYG editor, Action Text. It works out of the box quite well, but chances are that you want to add some custom functionality. This card contains...
...some tips how to achieve this. Setup Basically, follow the guide in the Rails documentation. The automated script may not work with the way webpacker is configured in your project...
...the sudo password with johndoe ALL=(ALL) NOPASSWD: ALL. # Run this script with e.g. `rails runner lib/scripts/benchmark.rb` require 'open3' # For debugging # Rails.logger = Logger.new(STDOUT) # ActiveRecord::Base.logger = Logger.new(STDOUT)
...check Nokogiri::VersionInfo.instance.warnings for any warnings (though they should appear e.g. when launching a Rails console) or Nokogiri::VersionInfo.instance.to_hash to view more information. Note If your application uses Spring...
...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...
position: relative left: -50% float: left .clear clear: both Together with this helper: # Rails 3 def center_float(&block) concat( content_tag(:div, :class => 'center_float_outer_container') do...
...tag(:div, :class => 'center_float', &block) end end + content_tag(:div, :class => 'clear') ) end # Rails 2 def center_float(&block) html = "".html_safe html << content_tag(:div, :class => 'center_float...
...in webpack.config.js: { ... optimization: { minimize: true, minimizer: [ new TerserPlugin({ terserOptions: { ..., mangle: { properties: { regex: /^[_#]/ } } } }) ] } } Configuring Webpacker (Rails) To configure Webpack to mangle private properties, make a change to your Terser configuration in...
.sort_by(&:last) .to_h end end Just paste that snippet into a Rails console and use #count_by now! Usage examples Number of email addresses by domain: > User.all.count...
...Article.all.count_by &:brand Note that the last simple example can also be achieved with Rails internals: Article.group(:brand).count. This translates to SQL, so it executes fast. However, grouping is...
...like above: new(str, safe_level=nil, trim_mode=nil, eoutvar='_erbout') Difference between Rails mailer and ERB Rails mailer <% if true %> <%= 'bar' %> <% end %> <%= 'foo' %> <%= 'bar' %> bar foo bar
...this requires the PP class from the pp gem. It is loaded in any Rails app already, but for plain Ruby you may need to require it.
...some cases, a viable workaround is to turn your images into inline attachments. Note Rails provides a simple mechanism to achieve this: https://guides.rubyonrails.org/action_mailer_basics.html#making-inline-attachments This documentation makes it look...
...It is recommended to watch for a feature flag, see below. return version unless Rails.config.feature_inline_email_images # `attachments` is provided by Rails, see the linked documentation above # URLs should...
This is quite an edge case, and appears like a bug in Rails (4.2.6) to me. Update: This is now documented on Edgeguides Ruby on Rails: If you set the...
...issues in specific scenarios. Why does this matter? Mocked time in tests Consider a Rails application where you use the remember_me feature of Clearance for authentication. The cookie for...
The linked article suggests an interesting way to speed up tests of Rails + Postgres apps: PostgreSQL allows the creation of “unlogged” tables, which do not record data in the PostgreSQL...
...the project might need to re-recreate their test databases like so: bundle exec rails parallel:drop && bundle exec rails parallel:prepare
We recently migrated a Rails application from yarn to npm. We decided to go this step instead of upgrading to > Yarn 2.0 to reduce the number of dependencies in our...
...your yarn.lock (after the first npm install you can relax the constraints again). jsbundling-rails supports NPM since v1.2.2. geordi supports package managers other than yarn since v11.1.0...
...posts"."user_id" = "users"."id" WHERE (posts.id > 10) Using includes usually works nicely, but Rails will apply some magic, as mentioned at the beginning of this card. This is subject...
...end-to-end test for every small requirement. After we integrated Jasmine into a Rails app we often add an E2E test that opens that Jasmine runner and expects all...
...and decide if any of it needs an update. Your main components (e.g. Ruby, Rails, Unpoly) should always be reasonably up to date. Keeping your dependencies up-to-date is...
RSpec.configure do |config| config.include Aegis::Matchers end In very old versions of Rails and RSpec you need to do this instead: ActiveSupport::TestCase.send :include, Aegis::Matchers
The goal is to get Jasmine specs running in a Rails project using Webpacker, with the browser based test runner. Should be easily adaptable to a pure Webpack setup.
...is still true', () => { expect(true).toBe(true) }) }) Step 3: Add a /jasmine page in Rails # config/routes.rb Rails.application.routes.draw do # ... if Rails.env.development? || Rails.env.test? get 'jasmine', to: 'jasmine#index' end end # app/controllers/jasmine_controller.rb
...are verified. Note that this is enabled by default when you are using rspec-rails along with verifying doubles. So if you really need to verify some dynamically defined methods...