我在一个多态关系的模型上从一个非常基本的范围得到了一些奇怪的结果。以下是这些关系的简要总结和细节。
模型/金融学
class Financial < ActiveRecord::Base
belongs_to :financiable, :polymorphic => true
#ltm is a boolean field in the model
scope :ltm, -> { where(ltm: true).last }
然后是一个基本的公司模型,它有很多金融机构
型号/Firm.rb
class Firm < ActiveRecord:
我有三个模特:
公司、汽车、乘客
公司hasMany轿车
轿车hasMany乘客
这些关系似乎是独立运作的:汽车显示所有乘客,公司展示所有汽车。
但我无法解决公司的问题-乘客(显示公司的所有乘客)。
我的公司负责人:
function index(){
//grab all companies and pass it to the view:
$companies = $this->Company->find('all');
$this->set('companies', $companies);
我需要一些子查询的帮助。我的问题似乎很简单,但我想不出来。
我有三个实体:-公司-汽车-雇员
雇员有一份公司名单(但公司没有员工名单)。汽车只有一家公司。
我要从每一家员工能接触到的公司取回所有的汽车。
数据库结构,以防有帮助。
公司
id | Name
雇员
id | Name
CompanyToEmployee
employee_id | company_id
Car
id | Name | company_id
随着gmiley的建议,我正在添加一些mora信息。
到目前为止,我所做的并不多。
ICrit
伙计们,我想从雅虎金融公司的国家--美国,从雅虎金融公司的个人资料页面上刮来刮去。联系是:
https://finance.yahoo.com/quote/AAPL/profile?p=AAPL
我试过这段代码,但无法解压缩。我是新的刮数据,如果你能帮助我。
我的代码:
import requests
from lxml import html
xp = "//span[text()='Sector']/following-sibling::span[1]"
symbol = 'AAPL'
url = 'https://finan