Posts by Breno Perucchi • 291 points
17 posts
-
1
votes1
answer54
viewsA: How to display to admin the specific data of each user chosen with Rails
Faria via a native Rails Ajax request (Unobtrusive Javascript). http://guides.rubyonrails.org/working_with_javascript_in_rails.html First you have to define what this modal will show, create in your…
-
1
votes1
answer82
viewsA: Ruby on Rails - .html.erb file does not update on the server
If Voce is running your application on the server then every time Voce makes a change it will be necessary to restart the Rails server for the changes to be updated. If your application is locally…
-
0
votes3
answers295
viewsA: Display fields from a hash in the view
sql = "SELECT products.cod as cod_produto,products.descricao as desc_produto,colors.descricao as desc_cor,sizes.descricao as desc_tamanho,products.price as preco,variations.quantity as…
-
1
votes2
answers59
viewsA: Javascript - How to add to all href="" of a div a domain "http://site.com"
I am using jquery #I edited $(document).ready(function(){ $(".recommendation-shelf").change(function() { $('.recommendation-shelf').find('a').each(function(i, obj) { var href = $(obj).attr('href');…
javascriptanswered Breno Perucchi 291 -
1
votes1
answer185
viewsA: Autocomplete Rails 4 + jQuery
# you can use Gem https://github.com/argerim/select2-rails or the pure JS itself. Gemfile adds this In "Lect2-Rails" In your app/Assets/Javascripts/application.js: //= require Select2 Add to your…
-
0
votes3
answers3061
viewsA: Update a specific DIV without refreshing the page
using unobtrusive javascript in Rails links #view <% form_tag @molecular_bio, url:edit_molecular_path(@molecular_bio) :method => :get, :remote => true do %> <p> <%=…
-
0
votes1
answer69
viewsA: pull data from a third table in a single relation
It got a little complicated, but you’re not bringing changing the ID by the NAME? f.select :estudoanimais_id, Estudoanimal.all.collect{|ea| [ea.id, ea.especie.nome]}
-
0
votes1
answer79
viewsA: Nested Attributes Rails Child model not saved
accepts_nested_attributes_for :contacts, reject_if: lambda {|attributes| attributes['kind'].blank?} In your view and on customer_params i did not find the attributo Kind will be the…
-
0
votes1
answer120
viewsA: Rails 4 Error each_with_index when using activerecord-import
array = ['#{tmp.order_id}','#{tmp.cod_produto}','#…
-
1
votes1
answer33
viewsA: Saving father and son if both are valid in Rails
In my opinion the best thing you can do is to create a nested form using the drive fields in the protocol view itself. remove after_create from protocolo.rb or use on ProtocoloController.rb…
ruby-on-railsanswered Breno Perucchi 291 -
1
votes1
answer330
viewsA: Problem with nested form has_many through using dynamic form
first class RecordForm < ActiveRecord::Base has_many :record_form_fields has_many :appointment_record_forms, dependent: :destroy has_many :appointments, through: :appointment_record_forms…
-
0
votes1
answer67
viewsA: Performance problem when returning json with rabl after query with activerecord
As recommended by Carvalho paste your code into text. It will be much simpler to help you and you will get help easier and faster if you do it the right way. /editing-help#code About your code. One…
-
2
votes1
answer63
viewsA: How to upload file via ajax with Rails 4?
https://www.sitepoint.com/asynchronous-file-uploads-rails/ https://github.com/JangoSteve/remotipart…
-
1
votes1
answer300
viewsA: Summing values of a column of a Ruby-related entity
You can use the relationship itself to sum up the values sale.products.sum(:price) To get these querys out of the view you have to learn to use the feilds_for…
-
0
votes2
answers445
viewsA: How to query a polymorphic relationship in Rails 3/4?
You want to bring all Jobs Approved from an object? Job.first.activities.where(state:'approved') Want to bring all activities that are related to Job?…
-
1
votes2
answers78
viewsA: How to register a new Person when you create a new Customer
As dpedoneze commented check if you are instantiating the build_person object before starting fields_for I would start this way in the view: f.object.build_person if f.object.person.blank?…
-
0
votes4
answers396
viewsA: Select without id field (Ror)
You can also use active record and make a map Model.where(name: 'Cristina', email: '[email protected]').map{|m| {name: m.name, email: m.email}}