我知道这个版本还没有正式发布但我今天检查了rc3,我注意到我不能再在我的序列化器中使用Rails url helpers.在0.8.x版本中,我可以执行以下操作:
class BrandSerializer < BaseSerializer
attributes :id, :name, :slug, :state
attributes :_links
def _links
{
self: api_v1_company_brand_path(object.company_id, object.id),
company: api_v1_company_path(object.company_id),
products: api_v1_company_brand_products_path(object.company_id, object.id)
}
end
end
Run Code Online (Sandbox Code Playgroud)
但这在新版本中是不可取的.解决这个问题的最佳方法是什么,以便我可以在链接器中保存链接?
编辑:现在我正在做以下事情但很想听听是否有更惯用的方式.
class BaseSerializer < ActiveModel::Serializer
include Rails.application.routes.url_helpers
Run Code Online (Sandbox Code Playgroud) Graphql中删除突变的结果应该是什么?我正在使用graphql-ruby gem.这是我的变异的一个例子,但我只是不确定我应该作为回应返回什么.
Mutations::Brands::Delete = GraphQL::Relay::Mutation.define do
name "DeleteBrand"
description "Delete a brand"
input_field :id, types.ID
# return_field ??
resolve ->(object, inputs, ctx) {
brand = Brand.find(inputs[:id])
brand.destroy
}
end
Run Code Online (Sandbox Code Playgroud) 如果我可以使用rails资产管道预编译slim模板,那将会非常方便.我希望将我的模板粘贴在app/assets/html中并以这种方式提供它们.
这是我到目前为止所得到的:
# config/initializers/slim.rb
Rails.application.assets.register_engine('.slim', Slim::Template)
# config/application.rb
config.assets.paths << "#{Rails.root}/app/assets/html"
config.assets.register_mime_type('text/html', '.html')
Run Code Online (Sandbox Code Playgroud)
运行rake资产:预编译读取app/assets/html中的.html.slim文件,但它不编译它们,输出文件仍然具有.slim扩展名.
有没有办法让这项工作?
我正在使用Heroku CI(Beta)和我的rails应用程序,当我的测试运行时,它们都会因以下错误而失败:
WARNING: Rails was not able to disable referential integrity.
This is most likely caused due to missing permissions.
Rails needs superuser privileges to disable referential integrity.
cause: PG::InsufficientPrivilege: ERROR: permission denied: "RI_ConstraintTrigger_a_5199633" is a system trigger
Run Code Online (Sandbox Code Playgroud)
这与rails如何处理夹具记录的删除有关.它们不是试图找出删除记录的顺序,而是简单地关闭维护参照完整性的触发器.
在Heroku CI上运行测试时,这不是一个选项.有没有人有这个适当的解决方案?
我使用Visual Studio .NET和C#构建了一个Windows服务应用程序.这项服务将部署在几百台机器上,我正在寻找一种可靠的方法来监控应用程序.通过监视器,我的意思是,我只想检查以确保它正在运行,并检查每个客户端上的一些设置的状态.
这样做有一个共同的方法吗?