Posts by Danilo Cândido • 713 points
24 posts
-
3
votes2
answers144
viewsA: has_many through association [RAILS 3.2]
Hello, in ruby we have a more expressive way of adding items in an array. we can use << Here no matter how much we use the new it will save the object when added to an array. medico =…
-
4
votes1
answer105
viewsQ: Why does Ruby have two send and __send__methods?
Ruby objects have a method called send that we can call methods dynamically. class MyClass private def true_method? true end end Example: mc = MyClass.new mc.send(:true_method?)…
rubyasked Danilo Cândido 713 -
1
votes1
answer89
viewsA: RAILS Seed File Runs but Does Not Save Data in Database
In the example above you created 3 groups. The Group class has a relationship has_many :tipo_atividades You must have the instance of a Grupo example: # pegando o útimo grupo criado grupo3 =…
-
1
votes1
answer264
viewsA: Save only the year in a date field on Postgres! RAILS
In this case, you will have to change the field type in the database in your Migration. of - (instead of using datetime) create_table :nome_da_tabela do |t| t.datetime :inicio_ano t.datetime…
-
20
votes3
answers2779
viewsQ: What are React Hooks?
I would like to understand the concept and if possible with examples of this new Feature react. What will change in the way you create projects with React? The community seems to have enjoyed, what…
-
3
votes2
answers653
viewsA: Add object in Localstorage [Object Object]
localStorage store key value. To store a javascript object you must serialize this object using JSON.stringify: localStorage.setItem('userData', JSON.stringify(this.user)) Roundabout…
-
5
votes1
answer526
viewsA: React Route without link
First you must import the login on Main.js Main.js import Login from "./Login"; Then still inside your Main.js you must add the route <div className="content"> // Rota login adicionada…
-
0
votes1
answer182
viewsA: Identify number in array and change to a string
You are not giving the word to be exchanged in the parameters You need a Array of a size size and the word (word) that will replace the multiples of 3. def code(size, word) Array.new(size + 1) { |i|…
-
3
votes1
answer357
viewsA: What does arroba (@) mean in variables in Ruby?
It means that the scope of this variable, that is the limit that it can be accessed from within a class. It is a variable of instance. That code of yours is just a line, it’s hard to explain with…
rubyanswered Danilo Cândido 713 -
2
votes1
answer41
viewsA: "Actioncontroller::Parametermissing" error, even with form sending parameters
Bruno, that call params require permit is called Strong Parameters. In the first part, you must reference the class name. change of params.require(:title) for params.require(:game) in the second…
-
0
votes1
answer55
viewsA: Show all objects except those belonging to the logged in user
You can use Where.not. def index Pet.where.not(user_id: current_user.id) end more information - Where.not Rails…
ruby-on-railsanswered Danilo Cândido 713 -
0
votes1
answer45
viewsA: Heroku Rails 4 Assets do not load
Solved Errors were inside the files scss.erb. They didn’t properly call the Rails helpers image_tag and asset_path. My scss.erb files was as below. Wrong background: url(<%= image_path…
-
0
votes1
answer45
viewsQ: Heroku Rails 4 Assets do not load
After I have deployed these files below are not being loaded. This is my directory This is my application.Rb Here as they are being called <%= stylesheet_link_tag "home" %> <%=…
-
0
votes2
answers56
viewsA: Rails - query for non-connecting records
Read the Active Record Query Interface http://guides.rubyonrails.org/active_record_querying.html Associations…
-
1
votes1
answer81
viewsA: How to change an image using commandButton in Java Primefaces?
You will have to use the EL (Expression Language) of the first faces in the frontend. You probably have a class called NavioBean this class has an attribute called imagem (or img, whatever the name)…
-
0
votes2
answers52
viewsA: How to average the last table in Rails
The average result is not showing up at the end because you need that amount of <th></th> be the same amount of <td></td>. In your example you 12 <th> tags and only 3…
-
0
votes1
answer80
viewsA: How to make a table in a scaffold Rails with the attributes of another scaffold
When you use scaffolding it generates only part of the code. If you want to give more life to the software you need to write the relationships. You need to open the Book, Loan and Report classes and…
-
0
votes2
answers51
viewsA: How do I get these balls out?
Go to the gear icon and click Settings and search by renderWhitespace. and changes editor.renderWhitespace: "all" for editor.renderWhitespace: "none"…
visual-studio-2017answered Danilo Cândido 713 -
0
votes1
answer150
viewsA: Action for a borrow button on the Rails
Class name should always come with uppercase letter, example: Livro.find, therefore the mistake Undefined local variable or method 'livro' def load_livro if params[:livro_id] @livro =…
-
2
votes2
answers3115
viewsA: Error installing Gem pg
You need to install pg admin server on your machine first. sudo apt-get install postgresql postgresql-contrib libpq-dev
-
0
votes1
answer154
viewsA: Rails link to dynamic
In the example below I am sending the source path to the next page, you can do this using partial with the attribute locals. <%= render partial: 'form', locals: {path_origem:…
-
1
votes2
answers1434
viewsA: CEP and CPF validation API in Java
Caelum has an API for this that is also maintained by the community. Official website Stela Github…
-
0
votes1
answer103
viewsA: Check records for the same month
You can use Conta.where("created_at = ? AND situacao_id = ?", 1.month.ago, id_da_situacao) "1.month.ago" and "id_da_situacao" are the parameters used in Query.…
-
1
votes1
answer71
viewsA: Problem with Openshift + Mentawai
It seems that you are not sending to JSP your list and with that to tag mtw on the page gets broken. In the corresponding method that invokes your page you must send the list positions via "output".…