A. rails 模型除了数据库外还支持哪些类型的数据源
json格式,xml格式 hash格式等类型数据
B. iframe 在rails怎么使用
HTML代码:
<div ng-show="paragraph.show">
<span ng-click="addModify(paragraph)" class="glyphicon glyphicon-plus"></span>
</div>
<div ng-show="!paragraph.show">
<div class="input-group">
<div class="input-group-addon">
<span class="glyphicon glyphicon-globe" ng-click="addModify(paragraph)"></span>
</div>
<input ng-model="paragraph.modifyURL" type="text" class="form-control" placeholder="Please input the URL.">
</div>
<div class="">
<p>{{paragraph.modifyURL}}</p>
<iframe width="100%" height="100%" seamless frameborder="0" ng-src="{{trustSrc(paragraph.modifyURL)}}" ></iframe>
</div>
</div>
JS代码
$scope.trustSrc = (url) ->
$sce.trustAsResourceUrl(url)
$scope.addModify = (paragraph) ->
paragraph.show = !paragraph.show
C. Rails中给数据表添加字段,为什么没添加上
在已有数据库中的表添加字段:
1、通用式:
alter table [表名] add [字段名] 字段属性 default 缺省值 default 是可选参数
2、增加字段:
alter table [表名] add 字段名 smallint default 0 增加数字字段,整型,缺省值为0
alter table [表名] add 字段名 int default 0 增加数字字段,长整型,缺省值为0
alter table [表名] add 字段名 single default 0 增加数字字段,单精度型,缺省值为0
alter table [表名] add 字段名 double default 0 增加数字字段,双精度型,缺省值为0
alter table [表名] add 字段名 Tinyint default 0 增加数字字段,字节型,缺省值为0
alter table [表名] add 字段名 text [null] 增加备注型字段,[null]可选参数
alter table [表名] add 字段名 memo [null] 增加备注型字段,[null]可选参数
alter table [表名] add 字段名 varchar(N) [null] 增加变长文本型字段 大小 为N(1~255)
alter table [表名] add 字段名 char [null] 增加定长文本型字段 大小固定为255
alter table [表名] add 字段名 Datetime default 函数 增加日期型字段,其中 函数 可以是 now(),date()等,表示缺省值
3、(上面都是最常用的,还有其他的属性,可以参考下面的数据类型描述)
4、删除字段:
alter table [表名] drop 字段名
修改变长文本型字段的大小:alter table [表名] alter 字段名 varchar(N)
删除表: drop table [表名]
D. rails migrate 能不能给数据库添加注释
css 中只有 /* */ 之间是注释, 这可以多行, 或 一行
其 "势力范围" 只在 <style> 至 </style> 之间
JS 中,
// ... 是单行注释 ( CSS 没有这个 )
在 /* */ 之间都是注释, 这可以多行, 或 一行
但其 "势力范围" 只在 <script> 至 </script> 之间
留意一下大家的势力范围, 就不会搞错了
E. rails 中能不能使用相对路径
根据启动时给出的环境参数, 没有的话默认为development环境, 比如: rails s qa 在rails里 可以使用Rails.env得到一个ActiveSupport::StringInquirer字符串, 也可以使用Rails.env.development? 这样的方法判断
F. rails-to-trails什么意思
rails-to-trails
轨迹
G. 如何合并两个 activerecord:relation rails
Tries to create a new record with the same scoped attributes defined in the relation. Returns the initialized object if validation fails.
Expects arguments in the same format as Base.create.
Examples
users = User.where(name: 'Oscar')
users.create # #<User id: 3, name: "oscar", ...>
users.create(name: 'fxn')
users.create # #<User id: 4, name: "fxn", ...>
users.create { |user| user.name = 'tenderlove' }
# #<User id: 5, name: "tenderlove", ...>
users.create(name: nil) # validation on name
# #<User id: nil, name: nil, ...>
Source: show | on GitHub
H. 用rails开发怎么写api
看了下Redmine的源码,它的api实现使用的似乎是自己实现的一个view模板类型,可以输出json和xml等格式,这个类型是在在lib/redmine.rb里注册的:
?
1
ActionView::Template.register_template_handler :rsb, Redmine::Views::ApiTemplateHandler
所以再添加一个gem似乎不太合适,你可以仿照它现有的写法来做。
以/issues.json这个api为例:在issues#index这个action里的format.api就是处理api的,
I. 收到了[email protected]的订单信息 是诈骗吗
你买了车票后发的,信息能跟你买的核对上就是真的,或者看有没有别人用你的账号
如果没有购买车票那肯定是假的