小编shw*_*eta的帖子

有没有带有注释和绘图工具的高级股票图表库?

我正在 Rails 上的 ruby​​ 上工作。我需要一个非常先进的股票图表库,其中包括实时图表中的注释、绘图工具和指标,如下图所示:

在此输入图像描述

提前致谢。

javascript flash charts ruby-on-rails ruby-on-rails-3

6
推荐指数
1
解决办法
2900
查看次数

多个belongs_to到同一个表

我有两张桌子:

货币和利率

currencies: id:int, code:string, name: string

rates: id:int, top_currency_id:int, bottom_currency_id:int, rate:float
Run Code Online (Sandbox Code Playgroud)

我有两个活跃的记录:

class Rate < ActiveRecord::Base
  attr_accessible :bottom_currency, :rate, :top_currency, :top_currency_id

  belongs_to :top_currency, :class_name => 'Currency', :foreign_key => 'top_currency_id'
  belongs_to :bottom_currency, :class_name => 'Currency', :foreign_key => 'bottom_currency_id'
end


class Currency < ActiveRecord::Base
  attr_accessible :code, :name

  has_many :rates
end
Run Code Online (Sandbox Code Playgroud)

所以问题是:当我要执行以下代码时:top_currency = Currency.find_by_id(1)@test = Rate.where(:top_currency => top_currency)

我收到以下错误:

Mysql2::Error: Unknown column 'rates.top_currency' in 
'where clause': SELECT `rates`.* FROM `rates`  WHERE `rates`.`top_currency` = 1
Run Code Online (Sandbox Code Playgroud)

为什么Rails的魔法不起作用?

非常感谢.

ruby-on-rails model-associations ruby-on-rails-3

6
推荐指数
2
解决办法
8386
查看次数

从iframe内容中获取父元素的属性值

data-media如果我在iframe内容中运行脚本,有没有办法获取属性的值?

代码如下所示:

<div id="myDiv">
    <iframe data-create-resource-url="http://my.domain.url" 
       data-media="Song" 
       frameborder="0" 
       height="41" 
       src="https://different.domain.url" width="366">
     </iframe>
</div>
Run Code Online (Sandbox Code Playgroud)

我已经尝试了很多办法已经像window.parent.document或者top.document或者window.parent和其他可用的解决方案,但似乎并没有工作.

html iframe jquery ruby-on-rails

3
推荐指数
1
解决办法
7829
查看次数