我正在尝试使用RestClient使用post方法访问Web服务.我正在发送指定的授权令牌,但我仍然收到403状态错误,这意味着我被禁止使用该API.有什么方法可以看到使用http post发送的请求,以便我可以验证标头?我无法找到任何示例或任何文件提及如何做到这一点?
我的代码与此类似:
token = get_token
response = RestClient.post "https://api-dev.xxx.com/software/services/search/ABC",
:authorization => "Bearer #{token}"
Run Code Online (Sandbox Code Playgroud) 如果我在3个模型之间有多态关联:
评论
belongs_to :book, :class_name => 'Book', :foreign_key => 'ref_id', conditions: "comments.ref_type = 'Book'"
belongs_to :article, :class_name => 'Article', :foreign_key => 'ref_id', conditions: "comments.ref_type = 'Article'"
belongs_to :ref, :polymorphic => true
Run Code Online (Sandbox Code Playgroud)
对于给定的注释列表,如何从Title两个列Book和Article模型中选择不同的值?
例如,如果我必须列出书籍的标题和在一段时间内给出评论的文章,那我该怎么做呢?我可以很容易地挑选评论列表,但我要如何挑选与独特的游戏,从Book和Article?
例如:
Book
+--------------+
| Id | Title |
+----+---------+
| 1 | 'Book1' |
| 2 | 'Book2' |
| 3 | 'Book3' |
+--------------+
Article
+-----------------+
| Id | Title |
+----+------------+
| 1 | 'Article1' …Run Code Online (Sandbox Code Playgroud) 如何将Base64编码的字符串转换为带有破折号的十六进制编码字符串(基本上是uuid格式)?
例如,如果我有
'FWLalpF2T5mmyxS03Q+hNQ0K'
Run Code Online (Sandbox Code Playgroud)
那怎么能把它转换成:
1562da96-9176-4f99-a6cb-14b4dd0fa135
Run Code Online (Sandbox Code Playgroud)