alfajango.com

It occurred to me that many Rails/Passenger/Apache applications may have caching set up in a way that it appears to be caching, when it is not actually caching...

gem-session.com

Where there was once a consistent API to manipulate and hook into the lifecycle of a persistent object, plugins must...

github.com

...outputs a Rack application which you can either serve standalone or mount into your Rails app...

etag { current_user&.id } etag { current_user&.updated_at } end Under the hood, Rails generates an ETag header value like W/"f14ce3710a2a3187802cadc7e0c8ea99". In doing so, all objects from that...

...etag { current_user&.updated_at&.to_f } end You might even want to patch Rails' etagging logic so you don't have to remember doing that. Here you go:

makandra dev

Ruby 1.9.2 is very slow when loading files, especially starting Rails servers or running specs takes forever. Do yourself a favor and upgrade to...

When using form_for you can give the form's target URL either as a string or an array:

This is what worked for me in a Rails 4: # JSON data as first argument, then parameters patch :update, { some: 'data' }.to_json, id: id, format: :json

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

You might find that your Passenger ignores all RailsSomething directives in the vhost for your new Rails 3 application. The culprit is a file config.ru which makes Passenger consider your...

...application a Rack (non-Rails) application. To fix this you can either use RackEnv in lieu of RailsEnv (it works fine) or delete the config.ru. Unless you have a good...

.../etc/apache2/sites-enabled with something like the following ^ NameVirtualHost *:80 <VirtualHost *:80> ServerName application.local DocumentRoot /opt/application/public RailsEnv development RailsAllowModRewrite off <VirtualHost *:443> ServerName application.local DocumentRoot /opt/application/public RailsEnv development RailsAllowModRewrite off SSLEngine on...

end html end Full disclosure: Under the hood this uses the private Rails helper method split_paragraphs that simple_format uses. While it might break when upgrading Rails...

After switching to Rails 3 you may get a LoadError with the following message when trying to use your application via passenger: no such file to load -- dispatcher Your Passenger...

...up releases, not assets. In order to clean up assets, you can use capistrano-rails. Just require 'capistrano/rails' in Capfile and add the following config: # config/deploy.rb set :keep_assets...

...remove any older versions. If you are using Webpacker, you need to configure capistrano-rails. If you are on Rails 3, you cannot use this to clean up assets. :keep...

Empty CSPs with send_file If you use send_file from a Rails controller, you can send potentially dangerous files with an inline disposition iff you also send...

...would execute active content): Content-Disposition: attachment If you use send_file from a Rails controller, the default disposition is attachment. You can also set it explicitly: send_file @attachment.path...

...runs; Code Reviews include test badge; Automatically merge a PR on green tests Upgrade Rails 5 0 - 5 New Rails features are accessible Replace slider framework 4 4

When you run rake db:create and get this error message Couldn't create database for {"encoding"=>"utf8", "username"=>"root...

yehudakatz.com

Yesterday, there was a blog post entitled “What the Hell is Happening to Rails” that stayed at the number one spot on Hacker News for quite a while. The post...

...the comments on the post reflect deep-seated concern about the recent direction of Rails. Others have addressed the core question about change in the framework, but I’d like...

If you specify different ports, you can run multiple local webricks with rails server --port=300X at the same time...

...a dump from db/production_structure.sql: class LoadDump < ActiveRecord::Migration def up config = YAML.load_file('config/database.yml')[RAILS_ENV].symbolize_keys config[:flags] = Mysql2::Client::MULTI_STATEMENTS client = Mysql2::Client.new(config) sql = File.read...

github.com

...all requests to a Rack application. You can use Sinatra, raw Rack, or even Rails as your application, allowing you to build up an equivalent to the remote service you...

...comparison can often be seen with simple string comparison like so. # ❌ Not recommended if Rails.version > '6.1.7.8' || RUBY_VERSION > '3.1.4' raise Error, 'please check if the monkey patch below is still...

...comparison above works by coincidence. But chances are that you are not: For example, Rails version 6.1.10.8 would not raise an error in the code block above, because in an...

Accept: application/json This means the client will only understand JSON responses. When a Rails action is done, it will try to render a template for a format that the...

...pages/foo, application/foo with {:locale=>[:de], :formats=>[:json], :handlers=>[:erb, :builder, :haml]} This is because Rails tried to find a template like foo.js.erb but all it found was foo.html.haml (which the...

github.com

Our new scope-based authorization gem for Ruby on Rails has been released. This might one day replace Aegis as our standard authorization solution...