Hack of the day: A reverse for Rails' &:
Ever wondered if there is a reverse for Rails' .each(&:to_s) idiom? Turns out there is...
You probably already know, that you can abbreviate code like
dogs.each { |dog| dog.bark! }
with
dogs.each(&:bark!)
Now suppose it is the other way round and you have
bones.each { |bone| dog.eat!(bone) }
Good old Ruby already has a solution:
bones.each(&dog.method(:eat!))
dbconsole in Rails 3 requires the environment as the first argument
There is a bug in Rails 3's dbconsole script, which makes the following command open a database console for the development environment:
rails dbconsole -p test
You need to write this instead:
rails dbconsole test -p
Passenger booting Rails 3 application in wrong environment
Passenger gives you the possibility to define in which environment your app should be started.
This has to be added to the VirtualHost configuration for Apache for Rails 2 applications:
RailsEnv development
When running Rails 3, you need
RackEnv development
postgres_ext: additional Rails bindings for PostgreSQL
Adds missing native PostgreSQL data types to ActiveRecord and convenient querying extensions for ActiveRecord and Arel for Rails 4.x
Common table expressions
- Relation#with
- Model.from_cte
Arrays
Face.where.contains tags: %w[happy smiling] # Matching faces have both 'happy' and 'smiling' tags
Face.where.overlap tags: %w[happy smiling] # Matching faces have at least one of these tags
Face.where.any tags: 'happy' # Matching faces include the 'happy' tag
Face.where.all tags: 'dunno' # Not documented, try for yourself
...
Failtale
Free Hoptoad/Airbrake alternative which can capture exceptions from any platform. It comes with a Rails notifier and a RESTful API to write your own notifiers for Javascript, etc.
Should we some day wish to do away with the current way we deal with exceptions, this might be a good place to start.
makandra/consul
Our new scope-based authorization gem for Ruby on Rails has been released. This might one day replace Aegis as our standard authorization solution.
plus2/whereuat - GitHub
Adds a slide out panel to your Rails application that directs clients to test stories that have been marked as 'delivered' in Pivotal Tracker.
lib/rucksack_extras.rb at master from jamesu's rucksack — GitHub
Wrapper from Globalite API to the Rails 2.2 I18n API
SASS: The Better, More Powerful CSS - Intridea Design Blog
I am a huge fan of SASS (Syntactically Awesome Stylesheets) for styling Rails applications. I have been using it on all of my projects for quite a while now and have developed some great techniques that make it much easier to organize, write, and read stylesheets in an application
Agile Ajax » The Incredible Rising Version Number » Pathfinder Development
Noel Rappin discusses ways to keep up with edge Rails.
justinfrench's formtastic at master - GitHub
A Rails FormBuilder with semantically rich and accessible markup.
Tagaholic - Console Update With Your Editor
Rails’ script/console makes it easy to fetch, view and edit your database records. But can you edit those records as quickly as you edit code in your text editor? Riiight, like editing our database records in an editor is gonna happen? It already has.
pluginaweek's plugin_test_helper at master - GitHub
Simplifies plugin testing by creating an isolated Rails environment that simulates its usage in a real application
sandofsky's acts_against_douchebar at master - GitHub
A Rails plugin that delivers a special message to DiggBar users, or runs frame-killer javascript.
fesplugas's typus at master - GitHub
Effortless backend interface for Ruby on Rails applications. (Admin scaffold generator.)
metric_fu: A Ruby Gem for Easy Metric Report Generation
Metric_fu is a set of rake tasks that make it easy to generate metrics reports. It uses Saikuro, Flog, Flay, Rcov, Reek, Roodi, Subversion, Git, and Rails built-in stats task to create a series of reports. It's designed to integrate easily with CruiseControl.rb by placing files in the Custom Build Artifacts folder.
graysky's translator at master - GitHub
Rails extensions to simplify internationalization
sdsykes's read_from_slave at master - GitHub
Read_from_slave for Rails enables database reads from a slave database, while writes continue to go to the master
A/Bingo: RoR Split Testing by Bingo Card Creator
A/Bingo is a Ruby on Rails A/B testing framework written as a plugin.
SecureRandom -- Stop writing your own random number and string generators - Momoro Machine
Stop writing your own random string generators. Rails does this for you.
xing's flag_shih_tzu at master - GitHub
A rails plugin to store a collection of boolean attributes in a single ActiveRecord column as a bit field.
samdanavia's ambitious_query_indexer at master - GitHub
Ambitious Query Indexer is a Rails plugin to identify database indexes that are missing. Rather than looking at tables and guessing what needs indexing, it will locate and run as many queries as it can find and suggest indexes that could be added based upon its findings.
ryanb's trusted-params at master - GitHub
Rails plugin which adds a convenient way to override attr_accessible protection.... You can mark certain attributes as trusted for different roles.
eliotsykes's asset_fingerprint at master - GitHub
Asset Fingerprint Plugin for Ruby on Rails - allows you to use md5 or timestamps in query string or in asset filenames as suggested by Google Page Speed