To make the RSpec matcher of the authorization solution Consul work with Rspec 2.x read the following blog post...
{ page_count: match[1].to_i } else {} end end rescue StandardError => e Rails.logger.error("PdfAnalyzer failed to parse metadata: #{e.message}") {} end def self.analyze_later? true # default end end # config/initializers/active_storage.rb...
...Rails.application.config.active_storage.analyzers.append PdfAnalyzer # db/migrate/xxxxx_add_pdf_analyzer.rb class AddPdfAnalyzer < ActiveRecord::Migration[8.0] def up pdf_blobs = ActiveStorage::Blob.where(content_type: 'application/pdf') # Mark all existing PDF blobs as to-be-analyzed-again pdf_blobs.find_each do...
...to check all traits for mistakes. This behavior is likely to be caused by Rails' autoloading...
In the ruby shell (IRB) and rails console the return value of the previous command is saved in _ (underscore). This might come in handy if you forgot to save the...
...Ruby couterpart. Thus, it does a great job as YAML-doc, e.g. when writing Rails locale files. Did you know that ... << is a merge key (similar to & in SASS)
...add support for parallel tests. You can easily do that by setting config.root: config.root = "#{Rails.public_path}/system/#{Rails.env}#{ENV['TEST_ENV_NUMBER']}".freeze For debugging purposes (e.g. trying to hunt...
...separate environment. You you could read from an ENV variable instead of using your Rails.env. Suggested configuration In total, here is a suggested configuration that you can put into config/initializers/carrierwave.rb...
A look at Prawn, PDFKit, and Wicked PDF
...on our radar for a while. They seem to have made significant progress running Rails, reducing start-up time and becoming runtime-independent of the JVM. Also see Running Optcarrot...
With Rails 4, Concerns have become the “official” solution to the big-models problem. However, there’s a fair amount of controversy about this topic in the community. Not everyone...
...problem of AR models becoming too big. In this talk we will see what Rails Concerns are and how can we use them to keep our models fit. More interestingly...
...lot more gems than you think. E.g. when you do this: bundle update cucumber-rails ... you might think this will only update cucumber-rails. But it actually updates cucumber-rails...
...breaking API changes. Which is all the time. In the example above updating cucumber-rails will give you Capybara 2.0 (because capybara is a dependency of cucumber-rails), which will...
...t say is_a?(ActiveRecord::NamedScope::Scope) because that is no longer true in Rails 3 and also doesn't match unscoped ActiveRecord classes themselves (which we consider scopes for...
If you have a file that looks like a precompilation fingerprint, the Rails asset pipeline will not see it. So don't have filenames like this: 8e21264d-f678-4005-b90c-8d8288a0d179.ttf
Say you want to allow users to emphasize some string, but the whole markdown thing would be far too much...
...remember to set your values with field=#{quoted_true} and field=#{quoted_false}. The Rails methods quoted_false and quoted_true return the correct boolean representations for your database...
...to iterate over every Monday in a range of Dates. If you are using Rails or ActiveSupport, calling step without a block will return an array of matching elements...
...but give sub-classes a way to override values without affecting the parent class. Rails has many helpers for this such as class_attribute and class_inheritable_accessor. Unfortunately their...
...semantics are hard to understand, the helpers available differ for different versions of Rails and the behavior is subtly different. Make sure you read and understand the API before using...
This means Basecamp migrated from the first Rails release up to the edge one. So how come people say so frequently how hard is to update their applications from Rails...
...to Rails 2.2? And the answer is simple: plugins...
Now supports RSpec 3 and Rails 4 Drops support for state_machine, which has some issues with Rails 4 and isn't actively maintained
It is common in Rails 3.0 applications that you want to provide default views for a group of controllers. Let’s say you have a bunch of controllers inside the...
...for Admin::PostsController and “app/views/admin/posts/index.html.*” is not available, it should then render “app/views/admin/defaults/index.html”. Since Rails 3.0, we have a new abstraction called resolvers that holds the logic to find a...
...can never change them without forcing users to empty their cache. Note By default Rails sends a header Cache-Control: max-age=0, private, must-revalidate with all responses, including...
...cached by browsers. You do need to pay attention if you redirect outside of Rails, e.g. via your web server configuration. Dealing with incorrectly cached redirects The only fix is...
...sure not to mess with that. Related cards If you are using Ruby on Rails, a use case / implementation might look like Rails 3: Sending tempfiles for download.
...Sass and Less files, so the theme can easily be integrated into your usual Rails application. Implements only Bootstrap features which means that some Material stuff is missing, but also...
The same applies to files in Carrierwave. Variant: Deliver attachments through Rails The first way is to store Paperclip attachments not in the default public/system, but in...
...can be configured like this: class Note < ActiveRecord::Base has_attached_file :attachment, :path => ":rails_root/storage/:rails_env/attachments/:id/:style/:basename.:extension" end To link to the protecting controller actions...
These two models can be used to access the posts and associated comments of a WordPress database.