Posts by Davis Roberto • 194 points
15 posts
-
0
votes1
answer24
viewsA: I have this error in form_for Undefined method equipment_index_path
I think your problem lies in the use of the word "equipments". If you open the Rails console run 'equipment'.pluralize you will see that the plural of "equipment" is "equipment". So I would do a…
-
0
votes1
answer82
viewsA: Change json format output in Rails?
You cannot do this. You have created an output for your list index, which shows all of them. If you want to create an endpoint to show a specific item, create a show route. def show @load =…
-
0
votes1
answer49
viewsA: Doubt when returning the amount of different letters
If you wanted to see if it is the same letter at each position (index) of the String: def letras(string_1, string2) contador = 0 string_1.split.each_with_index do |letra, index| counter += 1 if…
rubyanswered Davis Roberto 194 -
1
votes1
answer41
viewsA: Multiple classes for one student
First it is necessary to make a table N:N. rails g model student_rooms student:references room:references Now, we do the migrations to create the foreign_keys. rails g migration…
-
1
votes2
answers43
viewsA: Has_one association error
I think your relationships are a little messy. Take a look at documentation. In your case, instead of using the has_one, use a belongs_to. class Address < ActiveRecord::Base belongs_to :contact…
ruby-on-railsanswered Davis Roberto 194 -
2
votes2
answers250
viewsA: How to develop a specific layout for web and another for desktop?
You can make a different design for web and mobile using the @media of the CSS. For example, in my CSS I want a <div class="main-div"> has the background color of red. .main-div{…
-
5
votes1
answer280
viewsA: What is the difference between "==" and "is" in Python?
== compares whether variables have the same value. is checks whether both refer to the same object or not. x = [1, 2] y = [1, 2] x == y (true) x is y (false) x and y have the same value [1, 2], but…
pythonanswered Davis Roberto 194 -
-1
votes1
answer71
viewsA: Folder browsing
If you have the file open even in the browser, for example file:///Users/user/Desktop/Landing/index.html, You cannot do this because you are opening a folder from your computer. You can download VS…
-
2
votes3
answers252
viewsA: Number of odd numbers
You can make a counter. lista = [1,3,5,7,2,4] impar =[] def ehImpar(impar): impares = 0 for impar in lista: if impar % 2 != 0: impares += 1 print(impar) print(impares " números ímpares")…
pythonanswered Davis Roberto 194 -
0
votes1
answer41
viewsA: How to perform a has_many interaction query in Ruby on Rails
veiculos = Veiculo.joins(:multas).where.not('multas.tipo = ?', "cara")
-
1
votes1
answer125
viewsA: Make a list without EACH in Rails
It happens because of how you did the create of your Product. If you want a list only with the products of a certain customer you must modify in the controller @products = Product.where(user: {Seu…
-
0
votes1
answer40
viewsA: How to Nest a third nested_form in Rails
Missing a line in your models/questao.Rb accepts_nested_attributes_for :alternativas
-
0
votes1
answer89
viewsA: Vimeo Popup Video Does Not Open HTML
To run a Vimeo video from your website, you need to use their API. <div id="vimeo-video"></div> <script src="https://player.vimeo.com/api/player.js"></script> <script>…
-
0
votes1
answer101
viewsA: How can I get the html input for js
If you want to give one console.log() what the user has written on input, you can catch the tag by id and thus achieve its value. input = document.getElementById("ON") console.log(input.value) If…
-
0
votes1
answer2140
viewsA: How to define the tangent function in python?
Use the library math. She has a command called math.tan(x), in which it returns the tangent arc of x in radians. Example: import math math.tan(30) >>> -6.40533119665…