If Sunspot does not work and fails with a backtrace similar to this: /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:227:in `adapt_response' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:164:in `execute' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:158:in `send_and_receive'
then the schema.xml that is shipped with Sunspot is not loaded into Solr correctly. Often the latter can be found in /etc/solr/conf/schema.xml. So copy Sunspot's schema.xml there...
The httpclient gem comes with a custom SSL cert store.
...customizable, application-level cert store is great when you need to deal with broken or self-signed certificates, you usually want to use the cert store from the underlying Linux...
Sometimes you will need an input field which wraps content and grows in height as soon as content gets longer than the input fields width. There is no way to...
...get a "normal" string input field to wrap as desired, but there are other ways. Here is one pretty easy solution to get what you want: Step 1
...that is responsible for some (unexpected) behavior. You can use DOM Breakpoints for debugging subtree modifications, attribute modifications or node removal. Here you can see a very simple example that...
...shows what JavaScript lines are responsible for a text change (subtree modification): You can use this Code Pen if you want to try it yourself...
Getting started with Claude Code is super simple. Once you've made yourself familiar with it, you may want to improve your workflow. Here are a few quick tips that...
...are relevant to most users. Keyboard Shortcuts There are lots of keyboard shortcuts. Here are the most relevant ones. Insert a Newline To add a newline without submitting your prompt...
We usually ship applications that self-host webfonts to comply with GDPR. Many popular web fonts are available as NPM packages provided by Fontsource. We recommend using those instead of...
...downloading and bundling font files yourself. (See below for a list of benefits.) Usage Go to fontsource.org and search for the font you want to add (or a font that...
Sometimes huge refactorings or refactoring of core concepts of your application are necessary for being able to meet new requirements or to keep your application maintainable on the long run...
...different parts. Try to make tests green for each part of your refactoring as soon as possible and only move to the next big part if your tests are fixed...
Using ActiveRecord's #signed_id and .find_signed methods you can create URLs that expire after some time. No conditionals or additional database columns required...
AuthExternal pwauth Require group admin You need to first install libapache2-mod-auth-sys-group. You don't get any error message if you haven't installed it but...
...it doesn't work. sudo apt-get install libapache2-mod-auth-sys-group
...applications can be used by multiple users at the same time. A typical application server like Passenger has multiple worker processes for a single app. In a distributed deployment setup...
...like we use at makandra you will even have multiple application servers, each with their own worker pool. This means that your code needs to deal with concurrent data access...
...full trace reveals that ActionPack's action_controller/integration.rb is breaking while doing this: cookies = @headers['Set-Cookie'] cookies = cookies.to_s.split("\n") unless cookies.is_a?(Array) cookies.each do |cookie| name, value = cookie.match...
...happened for me. That is how my cookie looked when debugging: (rdb:1) puts headers['Set-Cookie'] remember_token=abcdef123456; path=/; expires=Mon, 31-Dec-2029 23:03:29 GMT...
There are cases when you need to select DOM elements without jQuery, such as: when jQuery is not available when your code is is extremely performance-sensitive
...an entire HTML document (which is hard to represent as a jQuery collection). To select descendants of a vanilla DOM element (i.e. not a jQuery collection), one option is to...
This card will show you how to use git rebase --onto without confusion. Use case You've got two feature branches (one and two), where two depends on one. Now...
...branched two from it (i.e. after code review the commits of branch one are squashed). Thus the commit history of branch one has changed. Branch two's history however didn...
...translation data {...
...} can not be used with :count => 1. key 'one' is missing. They seem to appear out of the blue and the error message is more confusing than helpful...
...all models on the activerecord.attributes level (or activemodel.attributes) instead of having the same translation string in each model's attribute block: # I18n file like en.yml en: activerecord: attributes: updated_at...
...to know them all, but we recommend Option 0 or Option 1. Option 0 (recommended): Sub-query with conditions from a scope You may also pass the existing User.active scope...
...the joined table: Post.where(user: User.active) This will make a single query. It uses a sub-query, which is slow in MySQL, but fast in PostgreSQL: SELECT * FROM posts WHERE...
Sometimes it might be helpful to have a version history for a gem, e.g. when you want to see if there is a newer Rails 2 version of your currently...
At first you should search your gem at RubyGems. Example: will_paginate version history. The "Tags" tab at GitHub might be helpful as well...
Use this MySQL command to show further info about a table: SHOW CREATE TABLE tags; This will output a table schema like this: CREATE TABLE `tags` ( `id` int(11) NOT...
A flaky test is a test that is often green, but sometimes red. It may only fail on some PCs, or only when the entire test suite is run.
...JavaScript periodically requests updates from a server to keep a in sync with the latest server-site data. Sometimes the test ended right after a polling request was sent, but...
This card compares patterns to store trees in a relation database like MySQL or PostgreSQL. Implementation examples are for the ActiveRecord ORM used with Ruby on Rails, but the techniques...
We will be using this example tree (from the acts_as_nested_set docs): root | +-- Child 1 | | | +-- Child 1.1 | | | +-- Child 1.2 | +-- Child 2 | +-- Child 2.1 | +-- Child 2.2
Note: Modern Rails has two build pipelines, the asset pipeline (or "Sprockets") and Webpacker. The principles below apply for both, but the examples shown are for Sprockets.
...your application uses many assets, such as images, javascripts and stylesheets. Without your intervention, the browser will request these assets again and again on every request. There is no magic...
...of pain like me, you can get to Xfce's native window manager by saying: xfwm4 --replace
You are not using javascript tests The file is served from a public folder (not via controller) Problem description If you deliver files from a public folder it might...
...be that the Content-Disposition header is not set. That's why the following spreewald step might raise an error: Then I should get a download with filename "..." expected: /filename...
DirectUpload allows you to upload files to your file storage without having to wait for the form to submit. It creates AJAX requests to persist the file within your form...
...and wraps them in a little API. This card will show you how to use it in order to create in-place file uploads with progress and a remove button...
...Ruby. def and define_method differ in which one they use. def Ruby keyword, starts a method definition Opens a new, isolated scope. Variables defined outside are not accessible inside...
...and vice versa. Defines an instance method on the receiver (specified before the method name, e.g. def object.foo); implicit receiver is the default definee The default definee is not self...