On any page accessed with SSL, all Ajax requests must use SSL, or they will fail. To make this happen...
decided to go fixtureless with Shoulda + Factory Girl. All good, except one problem. Slow as fuck tests. So here’s...
Even though the gradual engagement meme has been around for a while, and everyone just hates signup forms, they just...
The Juggernaut plugin for Ruby on Rails aims to revolutionize your Rails app by letting the server initiate a connection and push data to the client. In other words your...
MailStyle allows you to write the css for your html emails as you normally would, then writes the styles inline...
Rails 2.3 has a ton of really nice functionality locked up in monolithic components. I’ve posted quite a bit about how we’ve opened up a lot of that...
...of ActionController. ActiveModel is another way we’ve exposed useful functionality to you in Rails...
Info on install database_cleaner.
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...
Where there was once a consistent API to manipulate and hook into the lifecycle of a persistent object, plugins must...
...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:
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
You can use logs to locate a problem, e.g. by following the Rails log while you reproduce it, and add log output of your own.
...Unstuck — Joel Clermont, Laracon 2023 📄 Rubber ducking: not just a funny phrase Debugging tools 📄 Rails Guide: Debugging Rails Applications — the logger, the debug gem, web-console, and debugging memory issues...
...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...