Questions tagged as 'rails4'

0
answers

rqrcode_png rails controller - Passing by parameter the string contained in the bank

How do I pass the value that is in the field "codigo" of table "mesas" to the space below "VALOR_STRING_BANCO" ? How do I pass the value that is in the "codigo" field of the "mesas" table to the space below "...
asked by 21.09.2016 / 04:45
1
answer

Relationship Through Many-To-Many ActiveRecord

I have the following configuration in rails: Company has_many :company_products has_many :products, :through => :company_products Product has_many :company_products has_many :companies, :through => :company_products P...
asked by 13.09.2016 / 22:00
3
answers

Display fields from a hash in the view

I have a result of a variable that receives the output of an sql from postgres. I need to iterate in a view and I do not know how to display the given fields. In products_controller I have: def show sql = "SELECT products.cod as cod_pr...
asked by 06.08.2016 / 21:48
1
answer

How to implement login with attribute coming from another table with Devise in Rails 4?

I currently have a User Template that has a has_one relationship with Customer . In the customer tables I have the CPF field that the user informs when to register. I need to implement a login where the user inputs the e-mail...
asked by 08.09.2016 / 23:18
3
answers

Conditional Relationships

I need your help I have the following template: class User < Ac... enum user_type: [:normal, :admin] end I also have the "Department" template: class Department < A.... end What I need is to do the type relationship: U...
asked by 08.04.2015 / 12:11
1
answer

working with decimal {5,2} rails

I created my first API in Rails, and I'm using a simple template with to create a basic Crud, I managed to put my application to work I created the GET method cute little returned 200, only that in my POST it is returning the following error in...
asked by 29.01.2018 / 03:45
2
answers

Counter in model

I'm looking for a way to add a variable with increment to add to the id of a div, could anyone tell me the most recommended way to do this? My difficulty in making this increment is due to cocoon that is used to call this render <%= li...
asked by 09.12.2016 / 14:27
1
answer

Symbols in rails

After creating a template in rails can you change the created symbol? For example I created a template called transaction, rails creates in the plural transactions but would like to change that name for transactions is possible?     
asked by 29.09.2017 / 02:18
2
answers

List random objects

How could I generate random cars in the following model? would it be better to do this in the controller? class Pessoa < ActiveRecord::Base has_many :carros end     
asked by 26.09.2016 / 15:44
1
answer

Regular expression for zip file

How to add a zip file instead of an image? class UploadDatabase < ActiveRecord::Base has_attached_file :zip_file, styles: { medium: "300x300>", thumb: "100x100>" }, default_url: "/images/:style/missing.png" validat...
asked by 15.12.2016 / 18:24