Ever wanted to have your app virus-scan uploads BEFORE you attach them to a model? My BigAuthor app for writers and agents needed to do exactly that — I didn’t want some bozo uploading a virus-laden Word doc and then distributing to all the agents that log in to the site. So I set to [...]
Posts Tagged ‘rails’
Mongoid + Carrierwave + Virus scanning!
Posted: 30th December 2010 by M. E. Patterson in CodingTags: clamav, inherited_resources, mongoid, rails, ruby, virus
HOW TO: get fuzzy and plural matches from Sunspot / Solr
Posted: 5th October 2010 by M. E. Patterson in CodingTags: rails, search, solr, sunspot
Looked all over the place for a simple way to get Sunspot to give me back some basic ‘fuzzy’ search results, including ye olde “things that sound kinda like what I typed, even if I misspelled it” and “plural versions of the keywords I typed in.” It’s not that this is a super-hard problem that [...]
Nested forms, hashes, checkboxes and MongoMapper
Posted: 20th February 2010 by M. E. Patterson in CodingTags: inherited_resources, mongod, mongomapper, rails, ruby, solr, sunspot
While working on my upcoming BigAuthor project, I came upon an interesting challenge that turned out to be so simple with MongoMapper that I just have to share it here. Need to create a hash of multiple filter parameters on a MongoMapper document using a form that is cleanly resource-based, using InheritedResources? It’s not as [...]
Starting a new Rails app? Here’s my skeleton…
Posted: 15th February 2010 by M. E. Patterson in CodingTags: activerecord, gems, mongodb, mongomapper, plugins, rails
Not meant to be a “this is what should be done” as much as a “this is what Matt uses, based largely on community popularity, best practice, and Matt’s personal tastes.” Take it for what it is: a point of discussion. Of course, the skeleton of any Rails app will vary from project to project, [...]
Why use HAML (and SASS)? I already know HTML.
Posted: 2nd February 2010 by M. E. Patterson in CodingTags: haml, rails, ruby, sass
The title of the post is more-or-less a verbatim quote from a coworker, as well as from an unrelated colleague of mine from a previous job. I was asked that question and, to be honest, I was a little thrown both times. I didn’t actually know why I use HAML. I guess I’d never really [...]
Mongosphinx with MongoDB and MongoMapper
Posted: 20th January 2010 by M. E. Patterson in CodingTags: mongodb, rails, ruby, sphinx
Can that title have the word ‘mongo’ in it any more times? Well, fear not, I’m about to use it even more… So, I had to fool around a bit to get the so-called “Mongosphinx” gem working with my app architecture. Thought it might be helpful to others to demonstrate how I did it. I’ll [...]
Rails Metal + Thin = no ‘each’ for String?
Posted: 17th January 2010 by M. E. Patterson in CodingTags: rails, ruby, thin
Just solved an interesting problem when using the latest Thin web server (1.2.5) with Ruby 1.9.1 and Rails Metal. The code in Rails Metal endpoint: def call(env) if env["PATH_INFO"] =~ /^\/tags.txt/ request = Rack::Request.new(env) params = request.params query = params[’q'] [...]
Put all this crap in your ~/.aliases file. Do it! alias migrate="rake db:migrate db:test:prepare" alias remigrate="rake db:migrate && rake db:migrate:redo && rake db:schema:dump db:test:prepare" alias gadd="git add -u && git add . && git status" alias svnprecommit="git svn rebase && rake features && rake test" alias cuc="cucumber -r features" alias g="git" alias tu="ruby_test unit" alias [...]