Run multiple local webricks at the same time using different ports
If you specify different ports, you can run multiple local webricks with rails server --port=300X
at the same time.
Pattern: Disabling a certain feature in tests
There is a kind of features in web applications that hinder automated integration tests. Examples include cookie consent banners or form captchas. Clearly, these should be disabled so you do not have to explicitly deal with them in each and every test (like, every test starting with accepting the cookies notice). On the other hand, they must be tested as well.
A good feature disabling solution should therefore meet these requirements:
-
The feature is generally disabled in tests. A test does not need to do anything manually.
-
It is *...
We are no longer maintaining Dusen
If you were using Dusen for its query parsing and LIKE queries, we recommend to migrate to Minidusen, which extracts those parts from Dusen. Minidusen is compatible with MySQL, PostgreSQL and Rails 3.2, 4.2 and 5.0.
If you are looking for a full text indexing solution, we recommend to use PostgreSQL with pg_search.
Git: Issues with Gemfile.lock
When there's a Gemfile.lock
in your working directory that you cannot remove by either checkout
, reset [--hard]
, stash
, probably Rails' Spring is the culprit and not Bundler itself.
Fix
spring stop
The author of the linked Stackoverflow post supposes Spring re-writes the Gemfile.lock
on change to ensure all Spring processes are using the same gem versions. Meh.
danialfarid/angular-file-upload
Lightweight Angular JS directive to upload files
Includes polyfills for old IEs. Unfortunately, their auto-loading mechanism may not work properly on your Rails application due to the asset pipeline. They use FileAPI, so you could just include it manually for old browsers, or when you want to use FileAPI's toolkit anyway.
Always, always declare your associations with symbols
Never ever declare your associations with a string, especially when doing metaprogramming. A common mistake is something like
# WRONG
class Page < ActiveRecord::Base
%w[main sub].each do |type|
belongs_to "#{type}_title"
end
end
# RIGHT
class Page < ActiveRecord::Base
%w[main sub].each do |type|
belongs_to :"#{type}_title"
end
end
Always convert to a symbol, otherwise you'll have all [kinds](/m...
How much should I refactor?
The Rails community has been abuzz with object-oriented programming, SOLID principles, laws, design patterns, and other principles, practices, and patterns. We’ve (re)discovered new tools and techniques to separate and reuse logic, making code easier to test, understand, and maintain. Now that we’ve learned about all these new tools, when do we use them?
Incredibly fast web apps // Speaker Deck
Presentation about optimizing Ruby on Rails apps.
From Nico Hagenburger (homify's lead frontend developer).
Databound
Databound provides Javascript a simple API to the Ruby on Rails CRUD.
Tries to expose a full model CRUD as an API. Not sure if this is useful for more refined requirements.
ActiveRecord's where.not
Rails 4.0 introduced a helpful new method for ActiveRecord queries: where.not
. It can make clunky queries easier to read.
RailsPanel chrome extension
Chrome extension that shows all info from your rails log (like parameters, response times, view rendering times, DB requests) inside a chrome panel.
Redactor WYSIWYG html editor
New WYSIWYG editor that claims to be lighter and prettier than TinyMCE and CKEditor. Has some Rails integration, too.
King of Nothing, the DCI paradigm is a scam
I’ve worked on huge applications in Ruby and Rails before. I very much want to believe in DCI, but I’m having a hard time accepting the promises of Clean Ruby when it seems like the work on this paradigm is half-done. If it weren’t so oversold and hyped, I think I’d be more patient, but right now I’m just frustrated and confused.
RubyMine 4.5.1: Sass/SCSS Support Improvements
A number of issues concerning Sass/SCSS autocompletion and syntax highlighting were submitted as a feedback for RubyMine 4.5. Web development with Rails can’t do without Sass/SCSS code writing so we’ve decided to fix the most annoying bugs as soon as possible.
Modifying Rake Tasks - Dan Manges's Blog
For custom Rake tasks, you shouldn't need to modify them after the original definition. However, if you want to add behavior to some vendor tasks (such as those defined with Rails), this blog post will cover how to do that.
Difference between class_inheritable_attribute and class_attribute | martinciu's dev blog
How to make class_attribute
behave like class_inheritable_attribte
which no longer exists in Rails.
Aspect Oriented Programming in Ruby
Slides presenting ways to integrate the ideas of Aspect-Oriented Programming in Ruby.
Outline
- Why Aspect-Oriented Programming?
- AOP in Java and AspectJ (a Review).
- AOP in Ruby.
- What you can do today.
- Example AOP-isms in Ruby on Rails.
- Aspect-Oriented Design.
- The AOP Promise for Tomorrow.
fnando/i18n-js
A small library to provide the Rails I18n translations in Javascript clients.
Update: Aggregated RSpec/Cucumber test coverage with RCov
Our rcov:all
task for aggregated RSpec/Cucumber coverage was overhauled extensively. Among other things it now works for Rails 2 and 3 and has an option to ignore shared traits.
Cucumber.yml was found, but could not be parsed.
If you encounter the error message above when running cucumber, just execute...
rm rerun.txt
...in the Rails directory.
Or run...
tests
...from the geordi gem. This will do the work for you automatically.
Fix "undefined method `destroy'" in reset_session
This is a bug in Rails 2.3.11 which will be fixed in a future maintenance release.
Until then you can copy the attached initializer to config/initializers
.