Rails 4 MongoID嵌入式文档(Rails 4 MongoID embedded Documents)
我有以下型号
class Professional include Mongoid::Document field :first_name, type: String field :last_name, type: String field :company_name, type: String field :address, type: String validates :first_name, length: { minimum: 5, :message => "What" }, format: { with: /\A[a-zA-Z]+\z/, message: "only allows letters" } end
我想要包含一个嵌入式文档,我可以存储多个办公地址。 我正在寻找以下DB的结构
{ "first_name": "Harsha", "last_name": "MV", "company_name": "Mink7", "offices": [ { "name": "Head Office", "address": "some address here" }, { "name": "Off Site Office", "address": "some large address here" } ] }
I have the following model
class Professional include Mongoid::Document field :first_name, type: String field :last_name, type: String field :company_name, type: String field :address, type: String validates :first_name, length: { minimum: 5, :message => "What" }, format: { with: /\A[a-zA-Z]+\z/, message: "only allows letters" } end
I want to include a embedded documents where i can store multiple office address. Am looking for the following Structure of the DB
{ "first_name": "Harsha", "last_name": "MV", "company_name": "Mink7", "offices": [ { "name": "Head Office", "address": "some address here" }, { "name": "Off Site Office", "address": "some large address here" } ] }
原文:https://stackoverflow.com/questions/21375237
最满意答案
在这种情况下,你需要使用
.twocolumns
类来div没有你的标题,即像这样的h2元素<div class="article"> <h2>Biography</h2> <div class="twocolumns"> <p>Lorem ipsum dolor sit amet,....
并重置
p
元素的默认margin
和padding
以使其更清晰。p { margin:0; padding:0; }
所以基本上将
.twocolumns
类应用于那些要分成两列的元素。 在你的情况下,你不希望有标题。 所以把它从那里排除并把它放在外面。In that case you need to use the
.twocolumns
class to div that doesn't have your heading i.e. h2 element like this<div class="article"> <h2>Biography</h2> <div class="twocolumns"> <p>Lorem ipsum dolor sit amet,....
and reset the default
margin
andpadding
forp
element to make it more clear.p { margin:0; padding:0; }
So basically apply
.twocolumns
class to those element which you want to break into two columns. In your case you doesn't want to have heading in that. So exclude it from there and put it outside.
相关问答
更多-
IE7问题与文本对齐(IE7 issue with text alignment)[2023-03-09]
不要为锚标记定义text-align属性。在LI中使用它。 即 ul.site-map li{ text-align:left; } I was able to figure it out. For anyone with this issue in the future here is the simple fix: It appears that IE7 has an indentation/margin bug on list elements. To get around this, th ... -
文本未在2列中对齐(text is not aligned in 2 columns)[2022-03-23]
... 在自己绘制所有项目时,不是将ColumnHeader绘制为默认值,为什么不将所有项目作为默认值绘制并自己绘制ColumnHeader ? 我已经尝试过这段代码但是当鼠标结束时ColumnHeader的外观和感觉并不好,它不像ColumnHeader的默认外观,为了使它看起来类似,我相信我们需要更多的代码,不过因为我使用的颜色非常相似,所以并没有太大的不同。 您可以花更多时间来自定义它。 这只是一个演示: public Form1(){ InitializeComponent(); listView1 ...对齐2列文本(Alignment of 2 columns of text)[2023-03-30]
在这种情况下,你需要使用.twocolumns类来div没有你的标题,即像这样的h2元素Biography
Lorem ipsum dolor sit amet,.... 并重置p元素的默认margin和padding以使其更清晰。 p { margin:0; padding:0; } 所以基本上将.twocolumns类应用于那些要分成两列的元素。 ...
Vim:将文本与列对齐(Vim: Aligning text to columns)[2024-03-22]
我通常会首先将空格转换为#,然后使用对齐基于#对齐,然后删除#。 :%s/\ /#/g :'<,'>Align# :%s/\ /#/g 结果如下。 key:value1 key:value234 key:val0 key:val1 key:value1 key:value5 key:value65799 key:value356 key:3790 I would normally first convert spaces to #, then use Align to ...使用calc()的列对齐(Columns alignment using calc())[2021-10-04]
那么计算的主要问题是你必须减去分割前的边距宽度。 所以 .col-lg-4 { width: calc((100% - 10px) / 3 ); } 和 .col-md-6 { width: calc((100% - 5px) / 2); } Well the main problem with the calculation is that you have to subtract the margin widths before the division. so .col-lg-4 ...用于保存列对齐的CSV数据的HTML文本输入插件?(HTML text input plugin for CSV data preserving column alignment?)[2023-06-13]
编写脚本来替换celltags的选项卡和rowtags的换行符,如: r='foo\tbar\tfoobar\nbar\tfoo\tfoobar\nfoobar\tbar\tfoo'; r = r.replace(/\n/g,''); r = r.replace(/\t/g, ' '); r = '
'; alert(r); Write a script to repla ...' + r + ' Bootstrap列对齐(Bootstrap columns alignment)[2023-09-30]
首先,您需要在添加列之前添加一行,因为行的左右边距为-15px,列的两边都有15px填充,因此它非常适合div。 此外,当您添加cols和行时,请确保将其添加到容器中。 您可以覆盖行中的减去边距和列中的填充。 在检查之前添加一个包装form-group div的行 First of all you need to add a row before you add columns since rows have -15px margins from left and right and columns has ...这可以使用Bootstrap中的现有媒体查询来完成。 由于v.3首先是移动的,我将首先使所有内容居中,然后在下一个更大的媒体查询(768)上为需要左右对齐的元素添加样式。 我也编辑了你的代码: HTML