Questions tagged as 'ruby-on-rails'

2
answers

How to return null if no result found with find_by?

I'm getting a return as array ( [] ) from a scope with find_by and I want the return to be empty ( null ). Here are some snippets of the code: class Dispute::Conference < ApplicationRecord ... belongs_to :dispute,...
asked by 25.01.2017 / 12:03
1
answer

Id of the first table does not load in the DB

I'm trying to create a simple contact directory with two tables: Being one of them empresa :nome and the other contatos :nome :telefone :email ... I created the two tables and placed a Foreign_key in the second one that will receiv...
asked by 08.08.2014 / 20:24
3
answers

How do I work with tests and fixtures on a database that contains foreign key constraints in Rails?

I am using RubyOnRails 4.1 and PostgreSQL database and I use gem foreigner to create foreign key constraints in the bank. It turns out that this makes some tasks difficult with fixtures . When I try to run a test: spring rake test I...
asked by 21.08.2014 / 13:43
1
answer

Error saving the data marked in a questionnaire

I'm creating a survey that will save vehicles. For this I have to make a form divided into several pages but when I change the page the data marked in the radio buttons are lost Controller def new_vehicles @vehicle = Vehicle.new @vehi...
asked by 28.06.2016 / 20:56
1
answer

How do I get the exception Mongoid :: Errors :: DocumentNotFound released on Mongoid

To try to do a test similar to this below capture the exception of a nonexistent document expect(Produto.find('57e2bf76ce222fd11258cd4e')).to raise_error(Mongoid::Errors::DocumentNotFound) The exception message being passed is shown, howeve...
asked by 21.09.2016 / 19:34
1
answer

Doubt regarding float field query (ruby on rails with mysql)

Hello, I have a question regarding a database with rails. If I declare a field is "float", when I do the query, do I need to use ".to_float" for the rails to understand the type of this field? For example, in this calculation: def se...
asked by 06.10.2016 / 14:36
1
answer

Dynamic calculations in Rails

I hope you can help me. I have a Rated that has reviews , I have several calculations to determine whether or not it will go through a trial step. For example one of these calculations is calcula_pontuacao_minima() #Cálculo defi...
asked by 30.05.2014 / 01:03
4
answers

How do I create a button or a link to download a specific file?

I need to create a button that when clicked is downloaded and not opened in another tab or window. It can be any type of file both image, pdf, music among others.     
asked by 15.08.2014 / 21:02
1
answer

Error in db: create in Mac OSX Montain Lion

alexandesigner$ rails server dyld: lazy symbol binding failed: Symbol not found: _mysql_get_client_info Referenced from: /Users/alexandesigner/.rvm/gems/ruby-2.0.0-p353/extensions/x86_64-darwin-12/2.0.0-static/mysql2-0.3.15/mysql2/mysql2.bundl...
asked by 07.02.2014 / 12:50
1
answer

start server with vagrant on windows using git bash

As seen in the log below when starting the server such error occurs. Dei install and in sequence I tried to start the server. => Booting WEBrick => Rails 4.1.1 application starting in development on http://0.0.0.0:3000 => Run 'rails...
asked by 19.11.2014 / 03:53