小编Jor*_*uel的帖子

对于#<Array,未定义的方法`with_indifferent_access':

我已经尝试了很多方法,但它不起作用.我在这个项目中,另一个具有相同代码的控制器,另一个使用has_many关系的区别,有问题的是has_one和belongs_to.我们去看看代码.

class Endereco < ActiveRecord::Base
 has_one :user
end

class User < ActiveRecord::Base
 belongs_to :endereco
 accepts_nested_attributes_for :endereco
Run Code Online (Sandbox Code Playgroud)

控制器中的强参数:

class Backoffice::UsersController < BackofficeController

def create
 @user = User.new(params_user)
 respond_to do |format|  
  if @user.save!
    format.json { render json: @user, include: :endereco}
  else
    format.json { render json: @user.errors, status: :unprocessable_entity }
  end
 end
end



 def params_user
   params.require(:user).permit(:nome, 
        :email, 
        :password, 
        :password_confirmation, 
        :cpf, 
        :tel_fixo, 
        :tel_cel,
        endereco_attributes: [
          :rua,
          :bairro,
          :cidade,
          :uf,
          :cep,
          :referencia,
          :numero,
          :complemento          
          ])
  end 
Run Code Online (Sandbox Code Playgroud)

当我通过POSTMAN发送这个json时,我得到#Array的错误>未定义方法`with_indifferent_access':在这一行

@user = User.new(params_user)

{   "user":{
    "nome" : "teste1", …
Run Code Online (Sandbox Code Playgroud)

ruby ruby-on-rails

3
推荐指数
2
解决办法
5113
查看次数

当域不同时,如何将 Cypress 中的变量从一个测试(它)共享到另一个测试?

当域不同时,如何将变量从一个测试(它)共享到另一个测试?\n我尝试了无数种方法,使用别名、闭包、环境变量、本地存储,甚至使用事件侦听器,但是当下一个测试是执行后,这些变量将从内存中清除。

\n

重点是我需要在Web应用程序中获取开放协议的ID,然后去另一个域的后台验证该协议是否真的开放。\n这是放弃后的最后一个版本...

\n
/// <reference types="cypress" />\n\ndescribe("Testar abertura de protocolo no fale conosco", () => {\n    it("Deve acessar o FaleConosco, abrir um protocolo e depois validar no backoffice a abertura correta do mesmo", () => {\n        cy.visit(`${Cypress.env('FALE_CONOSCO_URL')}`)\n        cy.get("#BotaoCriarNovoChamado").click()\n        \n        cy.get('#InputLabelCpfCnpj').type("99999999999")\n        cy.get('#InputLabelEmail').type("email@email.com")\n        cy.get('#InputLabelTelefone').type("99999999999")\n        cy.get('#InputLabelAssunto').type("Assunto de teste")\n        cy.get('#InputLabelDescricao').type("Essa aqui e uma descri\xc3\xa7\xc3\xa3o bem detalhada, confia")\n        cy.get('#BotaoEnviar').click()\n\n        cy.get('#spanNumeroDoChamado').should('contain', 'N\xc3\xbamero do chamado')\n        cy.get('#divNumeroDoChamado').then($div => {\n            const numero_do_chamado = $div.text().split(' ')[3].replace(/^#/, "");\n            // cy.wrap(numero_do_chamado).as("minhaVariavel");\n\n            // Enviar o valor do alias para o segundo dom\xc3\xadnio …
Run Code Online (Sandbox Code Playgroud)

e2e-testing cypress

2
推荐指数
1
解决办法
121
查看次数

标签 统计

cypress ×1

e2e-testing ×1

ruby ×1

ruby-on-rails ×1