Posts by RafaelTSCS • 446 points
8 posts
-
0
votes2
answers356
viewsA: Read TXT file on Rails
respostas = [] File.open("caminho/do/arquivo", "r") do |f| f.each_line do |linha| (linha.scan /\w/).each_with_index {|val,i| respostas.push(i => val)} end end
-
0
votes3
answers601
viewsA: Mandatory fields depending on the form
You can create conditional methods in your model and handle conditional validations: validates :campo, presence: true, if: campoo_obrigatorio? def campo_obirgatorio? // retorno booleano end…
ruby-on-railsanswered RafaelTSCS 446 -
0
votes2
answers40
viewsA: Form with nested attribute and image upload
tries to change the campaign_params to: def campaign_params params.require(:campaign).permit(:name, :active, questions_attributes: %i(id title image campaign_id)) end I don’t know exactly if that’s…
ruby-on-railsanswered RafaelTSCS 446 -
1
votes1
answer161
viewsA: Rendered Does not work in datatable
You are sending the button to update the datatable "exibePerguntas", only that this datatable has a rendered. So, if there is nothing to show, this datatable does not exist and the button has no…
-
1
votes1
answer343
viewsA: SQL - How to count worked days
I believe that by putting DISTINCT in the COUNT, you will get the expected result: SELECT distinct NOME_FUN, EMPRESA,count(DISTINCT DATAR) as 'dias trabalhdos' FROM [RDO].[dbo].[ACESSOBROA_NOVO]…
sqlanswered RafaelTSCS 446 -
16
votes5
answers4312
viewsA: What does Nan mean in Javascript?
Nan stands for Not-A-Number. It means something is not a valid number. In this case, you are trying to parse from 'a' to INT, but 'a' is not a number, so the Nan error is generated (Not-a-number).…
-
6
votes1
answer930
viewsA: How to create variable dynamically?
Through this snippet of your code: constraints[0] = c1; constraints[1] = c2; I realize you’re putting the variables C1 and C2 into a vector anyway. So, using your example code, why not create these…
-
5
votes2
answers8501
viewsA: Synchronous requests
Since Javascript is "single thread", it is meant to be asynchronous. Otherwise, it would crash the browser if its synchronous request took too long and would display that annoying message to the…