Questions tagged as 'rails4'

1
answer

How to make a search field with form_tag in rails?

Hello! Good afternoon. I'm an information systems student and I'm doing a small project where I need to put a form to fetch the Product template objects that exist in the database. Product template: class Produto < ApplicationRecord be...
asked by 07.06.2017 / 20:12
1
answer

How to join 4 tables in SQL that is returning empty? (Inner, outer, or left join)

I have 4 tables with the following relationships: Products have N Variations Sizes have N Variations Colors have N Variations Variations belongs to Products, Sizes and Colors The structure of the tables looks like this: Variatio...
asked by 02.06.2016 / 19:21
1
answer

Select sex with enum

I made the select gender field this way: model: enum sexo: [:feminino, :masculino, :desconhecido] def self.sexes_for_select sexos.keys.map{ |x| [x.humanize, x] } end form: <%= f.select :sexo, Pessoa.sexes_for_sele...
asked by 19.10.2016 / 17:32
1
answer

Nested resources Rails

I created two models in the Rails application, and made their relationship through the declaration in the classes and in the database as well. I added the configuration to activate the nested resources in the routes file, the routes were created...
asked by 05.05.2016 / 02:56
1
answer

Rails inheritance

I'm starting in the area, I have the following scenario in my back end done in rails: I want to implement a parent class: Equipment: ID PK Brand ... And some child classes Printer: ID_EQUIPMENT PK and FK ... Computers: ID_EQUIPMENT P...
asked by 18.05.2018 / 20:53
1
answer

problem in file format validation with gem paperclip 5.1.0, rails 5

Model has_attached_file :foto validates_attachment_content_type :foto, content_type: /\Aimage\/.*\z/ Error in log Command :: file -b --mime "C:/Users/conta/AppData/Local/Temp/66c9eed121277d8be2df09ce25c4687a20171106-5872-1j1pihz.jpg" [pap...
asked by 06.11.2017 / 05:45
2
answers

Null return of an object in the controller - RAILS

Hello! I have the following code snippet from a controller called ProductsController: def index @produtos = Produto.all end def gerarlog @produtos.each do |produto| File.open('produtosBD.yml', 'a') do |arquivo| arq...
asked by 30.05.2017 / 21:01
1
answer

CoffeeScript on Rails - select items from a table

Hello! I have the following code generated by Scaffold: <p id="notice"><%= notice %></p> <h1>Produtos</h1> <table class="table table-striped" id="tabelaProdutos"> <thead> <tr> <t...
asked by 26.05.2017 / 16:26
1
answer

CSV In Ruby - Doubt

Good afternoon guys, I'm having a hard time understanding how Ruby works with csv, I need to read a file and import the data from that file into a variable I have a file named die.txt so Id | Nome | Endereco 1 | Renato | Alameda das magnol...
asked by 09.02.2017 / 16:41
1
answer

Prompt property is not working

<div class="field col-xs-3"> <%= f.label :modelo_id %> <%= f.select :modelo_id, options_for_select( @modelos.collect { |modelo| [modelo.nome.titleize, modelo.id] }, @carr...
asked by 22.10.2016 / 19:39