因为我在其他地方找不到最小的工作导轨版本:
我假设您已按照安装说明进行操作。
为了让 JQCloud rails gem 发挥它的魔力,一种方便的格式是哈希数组。通常我们在模型中构建它以保持控制器苗条,但为了展示一个最小的演示,您可以将以下定义放入控制器动作中:
@tag_cloud = [
{ text: "test", weight: 15},
{ text: "Ipsum", weight: 9, link: "http://jquery.com/"},
{ text: "Dolor", weight: 6, html: {title: "I can haz any html attribute"}},
{ text: "Sit", weight: 7}, {text: "Amet", weight: 5}
]
现在,在您相应的视图中,添加
<script type="text/javascript">
var word_array = <%= raw @tag_cloud.to_json %> ;
$(function() {
// When DOM is ready, select the container element and call
// the jQCloud method, passing the array of words as the first argument.
$("#example").jQCloud(word_array);
});
</script>
<div id="example" style="width: 550px; height: 350px;"></div>
...你应该看到词云。