Fixing "A copy of Klass has been removed from the module tree but is still active"
This can happen during development when classes without automatic reloading are pointing to classes with automatic reloading. E.g. some class in lib
is calling Model.static_method
.
Workaround A
Stop referencing autoloaded classes from static files. If you can't, see workaround B and C.
Workaround B
Make sure the offending file (the one referencing the autoloaded class) is autoloaded, too. You may do this:
# config/application.rb
config.paths.add 'offending/file/parent/directory', eager_load: true
Workaroun...
Configuring Git with .gitconfig
Basic configuration
Please keep this config simple. It should be a starting point for new developers learning Git.
[user]
name = Your Name
email = your.name@domain.com
[branch]
sort = -committerdate
[color]
ui = auto
[color "branch"]
current = yellow reverse
local = yellow
remote = green
[color "diff"]
whitespace = white reverse
meta = blue reverse
frag = blue reverse
old = red
new = green
[color "status"]
added = green
changed = yellow
untracked = cyan
[interactive]
singlekey = true # Do not requir...
Slugs with FriendlyId
Gem to provide nice looking urls ("/blog/the-greatest-bug-i-never-fixed"). If you don't need anything too special (like i18n for the urls) it works as a drop-in-replacement. It basically overwrites #to_param
to return the slug, and .find
to search by the slug.
Make sure, everywhere you build paths, you use model_path(:id => model)
instead of model_path(:id => model.id)
. You also need to adapt all code using something like .find_by_id
. The regular .find
is fine.
See the github README for installation instructions.
Don't forget ...
GNU httptunnel
httptunnel creates a bidirectional virtual data connection tunnelled in HTTP requests. The HTTP requests can be sent via an HTTP proxy if so desired.
Ruby, Rails, Web2.0 » Blog Archive » Great Ruby on Rails REST resources
I have been playing around with RESTful Rails recently. Below is my collection or Rails REST howtos, tutorials and other resources I have found so far.
Bill de hÓra: "Just" use POST
PUT means update the resource with this entity, which tends means "overwrite". Now think for a moment about how that works for things like tags in a blog post - if I leave the tag out, am I saying remove it? Ignore it? Do I have to echo back all the data so it doesn't get scrubbed?
mca blog [de hÓra: "Just" Use Post]
Once you start introducing partial updates, you open yourself for caching problems. doing partial updates means all cached copies of the original resource are now invalid.
mca blog [REST Upside Down]
i keep looking for ways to help people 'get' REST. not URLs or HTTP Methods; but REST itself - in a nutshell. so here's a new angle i've started playing with: "REST Upside Down."
Ruby on Rails » Keeping Up With The Joneses: Keeping Rails and its extensions up to date » Pathfinder Development
There are many wonderful things about Rails and the Rails ecosystem. A clean, well-lighted path for keeping all your extensions up to date is not one of them.
Mike On Ads » Blog Archive » Using your browser URL history to estimate gender
One of the things that I always wanted to do but never got around to was to analyze a user’s browsing history to estimate age and gender.
SourceForge.net: SWFRIP: Files
SWFRIP is a Macromedia Flash resource extractor and editor. It can save resources in various formats, including SVG conversion from the flash vector format, decompile ActionScript, and remove the protect tag from SWF files.
PragDave: The RADAR Architecture: RESTful Application, Dumb-Ass Recipient
So, as a result, people using RESTful ideas to talk to browsers have to put the smarts back on the server. They invent new URLs which (for example) return a resource, but return it all wrapped up in the HTML needed to display it as a form for browser-based editing.
paperplanes. run_later Gets Some Rails 2.3 Middleware Love
In earlier version I needed to do an awkward thing that only affected development mode, where Rails unloads all classes after each request. run_later runs code in a separate thread, and depending on how long that code runs the classes would be unloaded when they're still accessed from the worker.
ModPorter - Painless file uploads
Porter is essentially the inverse of X-SendFile. It parses the multipart post in C inside your apache process and writes the files to disk. Once that work is done it changes the request to look like a regular form POST which contains pointers to the temp files on disk.
rest-discuss : Message: Re: [rest-discuss] REST, HTTP, Sessions and Cookies
Most of the problems with cookies are due to breaking visibility,
Sam Ruby: Progressive Disclosure
Without intending to take anything away from Roy’s (valid) criticism on labeling, REST isn’t an all or nothing proposition. One can get significant value from partial adoption.
James on Software | Introducing Trample: A Better Load Simulator
Trample is a more flexible load simulator. Instead of a static list of urls, trample's configuration language is ruby. Using ruby's blocks (lambda functions), it's possible to randomize the requests that get made in each thread, as well as the user that logs in.
Using SSL in Rails Applications
On any page accessed with SSL, all Ajax requests must use SSL, or they will fail. To make this happen, all you need to do is include the names of the actions that service the requests in your ssl_required statement.
ActiveRecord Optimization with Scrooge - igvita.com
The idea behind scrooge is both surprisingly simple and powerful: instead of forcing the developer to manually specify each attribute column, simply observe and record for some period of time all of the attribute accesses and then reuse this knowledge in the future to automatically optimize your subsequent query requests.
aanand's deadweight at master - GitHub
Deadweight is RCov for CSS, kind of. Given a set of stylesheets and a set of URLs, it determines which selectors are actually used and reports which can be "safely" deleted.
MailStyle: A HTML Email Plugin for Ruby on Rails | Purify Blog
MailStyle allows you to write the css for your html emails as you normally would, then writes the styles inline when you send your emails. It also makes sure that your image paths are absolute rather than relative.
ActiveModel: Make Any Ruby Object Feel Like ActiveRecord « Katz Got Your Tongue?
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 functionality in ActionPack, making it easier to reuse the router, dispatcher, and individual parts of ActionController. ActiveModel is another way we’ve exposed useful functionality to you in Rails 3.