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
} } } } } Integration in Rails + searchkick Was benötigt man für Integration von Elastic in eine Rails-Anwendung? Mindestens: Client um mit Elastic zu reden Erzeugen von Indexen, passender Mappings + Migration...
...your jQuery version if desired. Here is an example how this might look: { "dependencies": { "@rails/webpacker": "4.x", "bootstrap-datepicker": "1.8.0", "bootstrap-sass": "3.4.1", "font-awesome": "4.7.x", "jquery": "2.2.4",
...be done by compiling the packs for production and search for a working example: RAILS_ENV=production bundle exec rake assets:precompile. Remember to remove the folder public/packs afterwards...
You need to set the :inverse_of option manually for relations that have an association to a polymorphic model. Otherwise...
The ActionDispatch module of Rails gives you the helper method flash to access the flash messages in a response. describe PostsController, type: :request do describe 'update' do it 'shows a...
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...
...helps to modify the Accept-Language in tests. Here is an example for a Rails application with Cucumber integration tests: class ApplicationController OVERRIDE_HTTP_ACCEPT_LANGUAGE = nil def accept_language...
end But how to solve the uniqueness problem? Another day, another undocumented Rails feature! This time, it’s that ActiveRecord::Base.connection.add_index supports an undocumented option to pass...
(excerpt from: Fancy Postgres indexes with ActiveRecord) So regarding to the cited site Rails 5+ allows me to use an SQL statement in my index: t.index 'shop_id, lower...
...tokens or CSP nonces. We have deprecated Rack::SteadyETag. We instead recommend reconfiguring your Rails app so two requests to the same resource produce the same HTML for a given...
The Rails logger will store its content in a buffer and write it into the file system every 1000 lines. This will come back to bite you when using Rails.logger.info...
...environments auto_flushing is set to write after each line. On production environments the Rails logger writes only every 1000 lines -- and not upon shell or script termination as you...
In Rails 2, you could use link_to_remote...
...:update => 'id' to...
...automatically replace the content of $('#id'). To do the same in Rails 3, include usual rails-ujs JavaScript, and put this into your application.js: $(function() { $('[data-remote][data-replace]')
If you require your Rails models manually, pay attention to the path you use. Unless you have to, don't do it at all. Background Consider these...
class Foo # something happens here end Now, when your environment is booted, Rails will automatically load your models, like User. In our example, when Foo gets loaded, it...
Rails includes milliseconds in Time / DateTime objects when rendering them as JSON: JSON.parse(User.last.to_json)['created_at'] #=> "2001-01-01T00:00:00.000+00:00" In RSpec you might want...
To offer files for download, use send_file. def download(file) send_file file.path, :disposition => 'attachment' end
Sometimes you want to have a time in a given timezone independent from you Rails timezone settings / system timezone. I usually have this use case in tests. Example
...return different results e.g. 2020-08-09 00:00:00 +0200 depending on the Rails timezone settings / system timezone. But in this example we always want to have the given...
...byebug 11.1.3 (the most recent version at time of writing) when using it with Rails 6 and it's new autoloading component, zeitwerk. There already is a issue for that...
When an object is created / updated, various callbacks are executed in this order: before_validation after_validation before_save
...concept worked really good. Here are two points that were extraordinary compared to normal Rails project with many UI components: Having a Rails application, that has no UI components (only...
...to look up different before you need to integrate an API component into your Rails application. REST API vs. GraphQL It is worth to consider whether you want to have...
If you get an error like this ... can’t find executable rails for rails-3.2.3 (Gem::Exception) ... one of several things might be wrong. You're using RVM
...possible that you have a system-wide gem executable (like rails) that requires a gem that is not available in the current RVM Ruby or gemset. Check what Ruby you...
Rails defines a #truncate helper as well as a method String#truncate. = truncate("my string", length: 5) = "my string".truncate(5) Both are really similar; in fact, the helper invokes...
If you use webpacker in your Rails application, and you have completely disabled Sprockets, you might get the following error when trying to deploy: Rails assets manifest file not found...
...This happens inside the deploy:assets:backup_manifest task. This task comes from capistrano-rails. It is build for Sprockets and does not work with Webpacker out of the box...
...capable of caching images. (FYI, here's how to do the upload all manually.) Rails setup Build these models: class Gallery < ActiveRecord::Base has_many :images, dependent: :destroy accepts_nested...
...connect a record to an already uploaded file = image_form.hidden_field :file_cache # Used by Rails to distinguish new from existing records = image_form.hidden_field :id # Used by Rails to know when...
The information in this card is only relevant for Rails 2.3-era apps. This note gives a quick introduction into caching methods (page caching, action caching and fragment caching) in...
...rails and describes some specific problems and solutions. The descriptions below are valid for Rails 2 and 3. Recently, caching with timestamp- or content-based keys has become more popular...
You may encounter problems with passenger starting an application with an updated rails. If you find an error like this in the apache error log...
...17680/7f4907ae7700 agents/HelperAgent/RequestHandler.h:2210 ]: [Client 19] Cannot checkout session. Error page: This application is a Rails 3 application, but it was wrongly detected as a Rails 1 or Rails 2 application...