This is for people recovering from Subversion.
git clone git@example.com:repositoryname
git status
git commit -m "good description"
git push
git pull
git add file
git add .
git checkout -b branchname
...
In Ubuntu your ALT key is locked when you're working in VirtualBox. There are two workarounds for this:
You are getting when connecting via SSH or deploying with Capistrano (which uses SSH):
Too many authentication failures for username
This is caused by having too many SSH keys added to your keyring or ssh-agent. Your ssh-agent will throw all keys against a server until one matches. Most servers will deny access after 5 attempts.
This issue might come and go as the order of the active SSH keys in your ssh-agent changes.
Have less keys. Up to 5 keys are fine when the SSHD you're connecting to is using the default ...
When you include a non-existing Javascript file, you probably won't notice it during development. But with caching active (on production or staging) Rails will write an empty all.js
file without complaining.
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 ...
Just assign the existing attachment to another record:
new_photo = Photo.new
new_photo.image = old_photo.image
Paperclip will duplicate the file when saving.
To use this in forms, pimp your attachment container like this:
class Photo < ActiveRecord::Base
has_attached_file :image
attr_accessor :copy_of
def image_url
if copy_of
copy_of.url
else
image.url
end
end
end
And in the controller do:
new_photo = Photo.new(:copy_of => old_photo)
This is more tricky than it should be because url_for
, asset_path
, etc. all rely on different mechanisms.
Anyway, you can use the attached trait like this:
class ExampleController < ApplicationController
does 'host_enforcement', :for => 'some_action'
end
Short explanation:
asset_host
is used for links to stylesheets and javascriptsasset_host
belongs to ActionController::Base
-- changes are persistent and will not be reset after a requestrewrite_options
is used by the ..._path
methods in the viewsAttached (see below) is some code to allow using unobtrusive JavaScript on pages fetched with an AJAX call.
After you included it, you now do not use the usual
$(function() {
$('.some_tag').activateStuff();
});
any more, but instead you write
$.unobtrusive(function() {
$(this).find('.some_tag').activateStuff();
});
that is
$.unobtrusive()
instead of $()
$(this)
Normal pages work as before (your $.unobtrusive
functions are ca...
Compress and obfuscate Javascript code online completely free using this compressor.
Insert into ~/.bashrc
and reload afterwards: source ~/.bashrc
PS1='${debian_chroot:+($debian_chroot)}\[\033[41;33m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ '
Below are 12 easy steps to follow if you're iPhone has experienced water damage.
RubySpec is a project to write a complete, executable specification for the Ruby programming language.
Ancestry is a gem/plugin that allows the records of a Ruby on Rails ActiveRecord model to be organised as a tree structure (or hierarchy). It uses a single, intuitively formatted database column, using a variation on the materialised path pattern. It exposes all the standard tree structure relations (ancestors, parent, root, children, siblings, descendants) and all of them can be fetched in a single sql query. Additional features are STI support, named_scopes, depth caching, depth constraints, easy migration from older plugins/gems, integrit...
The Rails router has been written and rewritten at least four times2, including a recent rewrite for the upcoming Rails 3. The syntax is now more concise.<br />
<br />
But never mind making it shorter! It’s time for a final rewrite: Let’s get rid of it altogether!
The jQuery project is really excited to announce the work that we’ve been doing to bring jQuery to mobile devices. Not only is the core jQuery library being improved to work across all of the major mobile platforms, but we’re also working to release a complete, unified, mobile UI framework.
You’re a business, calling a business, about conducting business. Don’t be surprised when money comes up.
The first thing I need to say, right off the bat: Chinese users will not buy your software. Period. That does not mean that there is no money to be made, it simply means that they will not pay for your software license.
Computer science is about tradeoffs and hard choices. Optimizing the code or design or architecture one way means taking hits another way.
Johnson wraps JavaScript in a loving Ruby embrace. It embeds the Mozilla SpiderMonkey JavaScript runtime as a C extension.
The Holy Grail of testing for front-end development; execute browser-less, console-based, javascript + DOM code right from within your Rails test suite.