Skip to content

Instantly share code, notes, and snippets.

class Basket < ActiveRecord::Base
has_many :fruits
def apples
fruits.where(type: 'Apple')
end
def oranges
fruits.where(type: 'Apple')
end
<?php
/*
* Implantation "made-in-OVH" de disk_free_space()
* ATTENTION : pensez à remplacer les arguments de
* $soap->login() avec votre propre identifiant et mot de passe.
* Vous devez aussi indiquer votre domaine dans $soap->hostingSummary().
*/
function ovh_free_space($path){
$cache_file = "data/quotas.cache.txt";
function ls-refresh {
while [ 1 ]; do ls -hdl "$1"; echo -n -e "\033[1A"; sleep 1; done
}
# Install ruby with RVM and Homebrew
$ xcode-select --install
$ gcc --version
$ ruby -e "$(curl -fsSL https://raw.github.com/Homebrew/homebrew/go/install)"
$ brew doctor
$ \curl -sSL https://get.rvm.io | bash -s stable --ruby
# Install PostgreSQL
$ brew install postgres
$ ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents
@ybart
ybart / example_root_route.rb
Last active August 29, 2015 14:13
Excerpts for URL Helpers articles
root 'welcome#index'
@ybart
ybart / config-application.rb
Last active August 29, 2015 14:14
Localizing ActionMailer::Preview
class Application < Rails::Application
...
# The easiest way : update the default locale and restart
config.i18n.default_locale = :fr
...
end
>> Ranking.all(:order => Ranking.clip.name.asc, :links => [:clip])
DataObjects::SyntaxError: no such column: clips.id (code: 1, sql state: , query: SELECT "rankings"."id", "rankings"."rank", "rankings"."progress", "rankings"."vote_count", "rankings"."votes", "rankings"."score", "rankings"."total", "rankings"."clip_id", "rankings"."jtop_id" FROM "rankings" INNER JOIN "rankings" "rankings_1" ON "clips"."id" = "rankings_1"."clip_id" ORDER BY "clips"."name", uri: sqlite3:/Users/ybart/Documents/Development/Rails/JTopStats/db/JTopStats_development.db?adapter=sqlite3&path=/Users/ybart/Documents/Development/Rails/JTopStats/db/JTopStats_development.db)
from /Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:147:in `execute_reader'
from /Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:147:in `read'
from /Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm-do-adapter/adapter.rb:276:in `with_connection'
from /Library/Ruby/Gems/1.8/gems/dm-do-adapter-1.1.0/lib/dm
doc = Nokogiri::HTML(open('http://www.nolife-tv.com/resultats_j-top'))
data = doc.css('.TBnl tr').collect{|r| r.css('td').collect{|d| d.content}}
File.open('test.out', 'w') { |out|
data.each {|row| out.puts row.inspect }
}
SELECT "rankings"."id", "rankings"."rank", "rankings"."progress", "rankings"."vote_count", "rankings"."vote_score", "rankings"."pal_count", "rankings"."pal_score", "rankings"."clip_id", "rankings"."jtop_id", "rankings"."prev_jtop_id"
FROM "clips", "rankings"
INNER JOIN "artists" ON "clips"."artist_id" = "artists"."id"
INNER JOIN "clips" ON "rankings"."clip_id" = "clips"."id"
WHERE "rankings"."jtop_id" = 80
GROUP BY "rankings"."id", "rankings"."rank", "rankings"."progress", "rankings"."vote_count", "rankings"."vote_score", "rankings"."pal_count", "rankings"."pal_score", "rankings"."clip_id", "rankings"."jtop_id", "rankings"."prev_jtop_id"
ORDER BY "artists"."name", "clips"."title";
ERROR: invalid reference to FROM-clause entry for table "clips"
LINE 1: ... FROM "clips", "rankings" INNER JOIN "artists" ON "clips"."a..
class Profile < ActiveRecord::Base
  belongs_to :license
  
  has_many :offers, :through => :application
  has_one :application, :through => :license  
end

I ran Profile.first.offers