Rails 3.0 introduced support for routing constrained by subdomains.
A subdomain can be specified explicitly, like this:
match '/' => 'home#index', :constraints => { :subdomain => 'www' }
=Navigating= | |
visit('/projects') | |
visit(post_comments_path(post)) | |
=Clicking links and buttons= | |
click_link('id-of-link') | |
click_link('Link Text') | |
click_button('Save') | |
click('Link Text') # Click either a link or a button | |
click('Button Value') |
$ rvm use 1.8.7-p302 | |
$ wget http://subversion.tigris.org/downloads/subversion-1.6.15.tar.gz | |
$ tar -xzf subversion-1.6.15.tar.gz && cd subversion-1.6.15 | |
$ ./configure --with-ruby-sitedir=~/.rvm/rubies/ruby-1.8.7-p302/lib/ruby --without-berkeley-db | |
$ make swig-rb && make install-swig-rb | |
To test things out: | |
$ irb | |
ruby-1.8.7-p302 > require 'svn/client' | |
=> true |
class User | |
has_attached_file :photo, | |
:processors => [:watermark], | |
:styles => { | |
:medium => { | |
:geometry => "300x300>", | |
:watermark_path => "#{Rails.root}/public/images/watermark.png" | |
}, | |
:thumb => "100x100>", | |
} |
def self.order(ids) | |
# The postgresql way | |
update_all(["position = STRPOS(?, ','||id||',')", ",#{ids.join(',')},"], { :id => ids }) | |
# the mysql way | |
# update_all(['position = FIND_IN_SET(id, ?)', ids.join(',')],{ :id => ids }) | |
end |
This installs a patched ruby 1.9.3-p327 with various performance improvements and a backported COW-friendly GC, all courtesy of funny-falcon.
You will also need a C Compiler. If you're on Linux, you probably already have one or know how to install one. On OS X, you should install XCode, and brew install autoconf
using homebrew.
# This example does an AJAX lookup and is in CoffeeScript
$('.typeahead').typeahead(
# source can be a function
source: (typeahead, query) ->
# this function receives the typeahead object and the query string
I spent a lot of time trying to find a pretty optimal (for me) setup for Clojure… at the same time I was trying to dive in and learn it. This is never optimal; you shouldn't be fighting the environment while trying to learn something.
I feel like I went through a lot of pain searching Google, StackOverflow, blogs, and other sites for random tidbits of information and instructions.
This is a comprehensive "what I learned and what I ended up doing" that will hopefully be of use to others and act as a journal for myself if I ever have to do it again. I want to be very step-by-step and explain what's happening (and why) at each step.
I'm hunting for the best solution on how to handle keeping large sets of DB records "sorted" in a performant manner.
Most of us have work on projects at some point where we have needed to have ordered lists of objects. Whether it be a to-do list sorted by priority, or a list of documents that a user can sort in whatever order they want.
A traditional approach for this on a Rails project is to use something like the acts_as_list
gem, or something similar. These systems typically add some sort of "postion" or "sort order" column to each record, which is then used when querying out the records in a traditional order by position
SQL query.
This approach seems to work fine for smaller datasets, but can be hard to manage on large data sets with hundreds (or thousands) of records needing to be sorted. Changing the sort position of even a single object will require updating every single record in the database that is in the same sort group. This requires potentially thousands of wri
Out of the box, Homebrew does a default installation on Sphinx:
$ brew install sphinx
However, if you're using MySQL, the thinking-sphinx gem won't work because it needs to use MySQL libraries.
If you managed to screw up the first time, uninstall sphinx first:
$ brew remove sphinx