class Profile < ActiveRecord::Base
belongs_to :license
has_many :offers, :through => :application
has_one :application, :through => :license
end
I ran Profile.first.offers
>> 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 |
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.. |
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 } | |
} |
class Profile < ActiveRecord::Base
belongs_to :license
has_many :offers, :through => :application
has_one :application, :through => :license
end
I ran Profile.first.offers
<% charts_js %> | |
<section id="content" class="body"> | |
<table class="data"> | |
<%= @clips.count %> | |
<thead><tr> | |
<th><%= sort_link 'Title', :title %></th> | |
<th><%= sort_link 'Entrée', :in %></th> | |
<th><%= sort_link 'Classique', :gold %></th> | |
<th><%= sort_link 'Top 10', :top10_count %></th> | |
<th><%= sort_link 'Top 20', :top20_count %></th> |
javascript:(function(){div=document.createElement('div');e=document.createElement('g:plusone');div.style.position='fixed';div.style.bottom='8px';div.style.right='8px';div.appendChild(e);document.body.appendChild(div);e=window.document.createElement('script');e.setAttribute('src','https://apis.google.com/js/plusone.js');document.body.appendChild(e);})(); |
module ActiveRecord | |
class Base | |
class << self | |
alias_method :old_method_missing, :method_missing | |
def method_missing(method_id, *arguments, &block) | |
if /^find_or_build_by_([_a-zA-Z]\w*)$/ =~ method_id.to_s | |
names = $1.split('_and_') | |
relation.find_or_build_by(names, *arguments) | |
else |
> ActiveRecord::Base.logger = Logger.new(STDOUT) | |
> Infrastructure::Radio.first | |
Infrastructure::Radio Load (0.8ms) SELECT "radio_channels".* FROM "radio_channels" LIMIT 1 | |
+----+------------+ | |
| id | ut_id_name | | |
+----+------------+ | |
| 1 | 245 | | |
+----+------------+ | |
> counter = 0; Infrastructure::Radio.first.foo.each {counter += 1}; puts counter |
applications_licenses GET /licenses/applications(.:format) {:action=>"applications", :controller=>"licenses"} | |
GET /licenses(.:format) {:action=>"index", :controller=>"licenses"} | |
POST /licenses(.:format) {:action=>"create", :controller=>"licenses"} | |
GET /licenses/new(.:format) {:action=>"new", :controller=>"licenses"} | |
GET /licenses/:id/edit(.:format) {:action=>"edit", :controller=>"licenses"} | |
GET /licenses/:id(.:format) {:action=>"show", :controller=>"licenses"} | |
PUT /licenses/:id(.:format) {:action=>"update", :controller=>"licenses"} | |
DELETE /licenses/:id(.:format) {:action=>"destroy", :controller=>"licenses"} |
module Associations # :nodoc: | |
extend ActiveSupport::Concern | |
module ClassMethods | |
def has_many(name, options = {}, &extension) | |
Builder::HasMany.build(self, name, options, &extension) | |
end | |
end | |
end |