Posts by Daniel • 1,222 points
72 posts
-
1
votes1
answer37
viewsA: How to capture an event in a stub? [Vue-test-utils]
That way you solved the problem <my-custom-form @submit.native.prevent="save"></my-custom-form> Reference link…
-
1
votes1
answer37
viewsQ: How to capture an event in a stub? [Vue-test-utils]
I’m trying to test an event similar to this: // template: <form @submit.prevent="save"></form> const save = jest.fn() const wrapper = mount(MyComponent, {methods: { save }})…
-
0
votes1
answer53
viewsQ: Optimize firebase cloud Storage
I’m developing an application using the Firebase Realtime Database and the Firebase Cloud Storage. According to the documentation, to access an image I need to invoke the method getDownloadURL in…
-
0
votes1
answer31
viewsQ: Firebase Cloud Function being called twice
I have the following function: 'use strict'; const functions = require('firebase-functions'); const admin = require('firebase-admin'); exports.myFunction =…
-
2
votes1
answer165
viewsQ: Angularjs ui-router application has /#! / in the URL
I have an app with ui.router working normally, but a second application has a "!" after the "#" Ex: http://localhost:8090/dev/#!/home Why does that happen? The normal should be:…
-
0
votes0
answers35
viewsQ: Handle socket disconnection in clients
For example: I have 5 mobile devices listening to events A device lost connection The server triggers an event Four connected devices receive the event Disconnected device loses event and then…
-
0
votes1
answer363
viewsA: Angularjs - the ng-class directive is not working
It is not good practice to access the document directly inside an angular component, but to solve its problem follows code example below. angular.module('app', []).controller('ctrl',…
-
0
votes0
answers26
viewsQ: Error adding Ionic-Platform-web-client
I have a perfectly functioning Ionic project. These are the versions I’m using: Cordova CLI: 5.3.3 Gulp version: CLI version 3.9.1 Gulp local: Local version 3.9.1 Ionic CLI Version: 1.7.14 Node:…
-
1
votes0
answers64
viewsQ: Change Request Headers to WS protocol
I have an app Ionic using an API Ruby on Rails. To authenticate, I am using Gems Devise and tiddle where I pass via the Angularjs X-USER-EMAIL and X-USER-TOKEN in the Request Header Have a part of…
-
0
votes2
answers91
viewsQ: Validation of has_and_belongs_to_many in Ruby on Rails
I have the following models: class Pedido < ActiveRecord::Base has_and_belongs_to_many :produtos validate :has_one_or_less_produtos private def has_one_or_less_produtos errors.add(:produtos, 'Não…
-
1
votes1
answer131
viewsQ: Post e Put com Restangular para api Ruby on Rails
I’m creating an app single page using Angularjs using an API ruby on Rails and the plugin restangular to effect my requests. Problem: The default API expects POST and PUT requests to arrive isolated…
-
0
votes3
answers81
viewsA: Spare me the news I’m clicking?
How are you calling the like() within a ng-repeat, recommend that you pass the id from ng-repeat for the function like(). It is common to have this type of problem, because in the loop of repetition…
-
1
votes2
answers1346
viewsA: Editing data with Angular and php
Here’s an example, I believe that’s what you’re trying to do. Hug. angular.module("myCrud", ["ngResource"]); angular.module("myCrud").controller("myCrudCtrl", function ($scope, $resource) {…
-
1
votes5
answers2441
viewsA: How to concatenate String within a repeat loop?
Replace the operator = for .= for($c=0; $c < $tam; $c++){ //concatenar sempre o valor $minhastring .= $valor[$c] . ','; }…
-
1
votes1
answer773
viewsA: How to make this directive return in ng-bind the sum of the results?
Below is an example of a solution in controller unused directive. Html <div ng-app="myApp"> <div ng-controller="myController"> <div ng-repeat="item in itens">…
-
0
votes1
answer95
viewsA: Pouchdb + Cordova not working
I performed tests on different versions of Android and found that the problem is in Android and not in the application. This version of Android for some reason when the application starts writing…
-
0
votes1
answer95
viewsQ: Pouchdb + Cordova not working
I’m developing an application using the Pouchdb and creating apps using Cordova. I already tested the application on Chrome, firefox, android browser, safari, Blackberry browser, app for Ios, apk no…
-
0
votes1
answer94
viewsQ: Deploy Ruby on Rails with Capistrano
When executing the deploy I have the following error: Rack app error: #<RuntimeError: Missing 'secret_token' and 'secret_key_bas' for 'production' environment, set these values in…
-
0
votes0
answers29
viewsQ: Advanced queries with "pouchdb-find"
How to do a search containing using the pouchdb-find? What I have so far is this but it doesn’t work as expected. db.find(selector: {title: "%" + $scope.pesquisa + "%"}) It is possible to do with…
-
0
votes2
answers146
viewsA: Advanced query in Ruby On Rails (Activerecord)
It is not possible to do Where with Count this way, you need to use the having. That solved the problem. Produto.joins(:cliente) .group(:nome, :quantidade) .having('count(produtos.id) <…
-
0
votes1
answer689
viewsA: Query using "select" and "joins" with activerecord in Rails 4
It just doesn’t show the column value you need because there isn’t a model in this format. Try this way: Add an alias to count(deducoes.id) as qtd Then run on your console: Deducao.joins(:prestador)…
-
10
votes2
answers14814
viewsA: What is the difference between an XML file and an XSD file?
The two files use the syntax of XML. The difference is that the XSD is used to validate a XML, what fields the XML should contain, among others, what their types are mandatory or not. There are…
-
0
votes2
answers146
viewsQ: Advanced query in Ruby On Rails (Activerecord)
I need to make a query for a report more or less like this: Produto.include(:clientes).where('count(produto.id) < cliente.quantidade') In sql would be more or less like this: SELECT C.NOME,…
-
0
votes1
answer117
viewsA: Test method of an Angularjs controller using Karma, Mocha, Chai, Sinon
For this problem reported above in specific the code below already solves the problem. describe 'create', -> it 'should call "new"', inject ($timeout)-> spy = sinon.spy productService, 'new'…
-
1
votes1
answer117
viewsQ: Test method of an Angularjs controller using Karma, Mocha, Chai, Sinon
I’m unable to test the code that runs on then of Promise I have the following controller: class Product extends Controller constructor: ($scope, productService) -> $scope.product =…
-
3
votes2
answers1232
viewsQ: Enable CORS in api Rails
They’re using this one GEM to enable the CORS of my application. The code I have in my config/application.rb is as follows: config.middleware.insert_before 0, 'Rack::Cors' do allow do origins…
-
5
votes1
answer326
viewsQ: SELECT with sequential counter does not accept LEFT JOIN
Because by making a SELECT that returns a Sequence number doesn’t work if you have LEFT JOIN? SELECT @ROW_NUMBER:=@ROW_NUMBER+1 AS ROW_NUMBER, P.PEDIDOID FROM PEDIDO AS P, (SELECT @ROW_NUMBER:=0) AS…
-
7
votes2
answers213
viewsQ: Heroku deploy with Bower-Rails
I have the gem 'bower-rails' installed in my application but when deploying I have the following error: I added the gem rails_12factor I’m using the buildpack: heroku buildpacks:set…
-
7
votes2
answers313
viewsQ: Access variable based elements
I need to assign the value to a label, example: xrLabel1.text = "teste", but as I have several Labels where changes only the number at the end example: xrLabel1.text = "teste"; xrLabel2.text =…
-
1
votes0
answers46
viewsQ: Skroll Stylesheet not working
I have the following code: Gem: gem 'skrollr-rails' Javascript: //= require jquery //= require jquery_ujs //= require turbolinks //= require skrollr //= require skrollr.menu //= require…
ruby-on-railsasked Daniel 1,222 -
0
votes1
answer33
viewsA: Load skrollr.init the right way in Rails
This being loaded correctly, to work just add the code as below: // => skrollr.init() s.refresh(); Thus the Skrollr will be reloading page elements. Official documentation…
-
0
votes1
answer33
viewsQ: Load skrollr.init the right way in Rails
I’m using the Skrollr in an application Rails as follows: Gem Utilizado: gem 'skrollr-rails' app/Assets/Javascripts/application.js //= require jquery //= require jquery_ujs //= require turbolinks…
-
1
votes1
answer241
viewsQ: Convert Datatable to List Entity
I’m trying to use the code below to convert but it gives error everywhere that has the T and where. What could be? // function that set the given object from the given data row public static void…
-
7
votes2
answers207
viewsQ: Regular expression start, end
I have two regular expressions: $exp1 = '/^abc.*\_20150430.txt$/' $exp2 = '/^def.*\_20150430.txt$/' Must return true for archives started by abc in the first and def in the second. In the two…
-
1
votes1
answer289
viewsQ: Extract hash in Ruby on Rails
I got the following Hash my_hash = {city: {id:1, created_at: '', name: 'test_city'}, uf: {id:1, created_at: '', name: 'test_uf'}} I need to extract some data from it ex: my_hash.extract!({city:…
-
0
votes1
answer115
viewsQ: Database configuration using rspec-Rails
In my spec/rails_helper.Rb I added the following code so that the database was automatically created when running rspec: def database_exists? ActiveRecord::Base.connection rescue…
-
0
votes1
answer61
viewsA: Template error no rspec-Rails
Add the following code at the beginning of the test: before(:each) do assign :q, City.ransack end
-
0
votes1
answer61
viewsQ: Template error no rspec-Rails
I’m using the rspec-Rails to test my application, however while testing a view using Ransak for filters I have the following return error: 1) admin/cities/index renders a list of admin_cities…
-
0
votes1
answer236
viewsA: Routes in ruby on Rails
Just add a alias for the route: resources :roles do resources :role_permissions do patch 'toggle_action/:id' => 'role_permissions#toggle_action', as: :toggle_action end end and to use it:…
ruby-on-railsanswered Daniel 1,222 -
2
votes1
answer236
viewsQ: Routes in ruby on Rails
I have the following routes: resources :roles do resources :role_permissions do patch 'toggle_action/:id' => 'role_permissions#toggle_action' end end I create a link as follows:…
ruby-on-railsasked Daniel 1,222 -
1
votes1
answer121
viewsA: Remove elements outside the standard deviation
Follows below in operation. Removes array values that are outside the standard deviation: Add methods in the Array class class Array def average return 0 unless self.size > 0 self.sum.to_f /…
-
0
votes1
answer121
viewsQ: Remove elements outside the standard deviation
I have the following array [123, 350, 3456, 98] and need to remove items outside the standard deviation as in this case the 3456. I have already calculated the standard deviation as below: class…
-
0
votes1
answer122
viewsA: Activerecord Labels using I18n
The method label uses helper translation only: helpers: label: city: codigo_municipio: "Código do município" If I already have the translation on activerecord. it is not convenient to duplicate the…
-
0
votes1
answer122
viewsQ: Activerecord Labels using I18n
I have the following code: en.BR.yml activerecord: attributes: city: codigo_municipio: "Código do município" View = label(:city, :codigo_municipio) Expected result: # => <label…
-
0
votes0
answers850
viewsQ: I18n Translate Enum
I have an Enum in my model containing the states, and I created a translation for it with I18n but it gives the following error: Translation data {...} can not be used with :Count => 1 My Enum:…
-
1
votes1
answer73
viewsQ: Add method to Activerecord::Base
I created a method in the Activerecord::Base and it uses another method to be defined in the model, I need to validate if the model method is defined before executing what I need, but it says it’s…
-
1
votes2
answers69
viewsA: Require files on Seeds.Rb
Use the code below to include all files in the folder Seeds Utilise Rails.root to get the full path to file. # Include ruby files Dir[File.join(Rails.root, 'db', 'seeds', '*.rb')].each do |filename|…
-
0
votes2
answers69
viewsQ: Require files on Seeds.Rb
I need to organize my file Seeds.Rb, so I created a namespace where I will add my ex classes: module Seeds class Apple def self.run puts 'teste' end end end Seeds::Apple.run This works perfectly,…
-
2
votes1
answer2203
viewsA: Assign function return to a variable using Angularjs $Promise
What happens is this, your getContent is an asynchronous function, so when you do the console.log($Scope.Node) the Promise was not yet resolved. When any attribution is made within a Promise it will…
-
0
votes1
answer63
viewsQ: Filter with Angularjs and Gulp
I’m creating a filter for the angular using the compiler Gulp however I am having an error and when analyzing the compiled code it seems that is compiling something wrong, what could be? Filter:…