Most voted "rails4" questions
65 questions
Sort by count of
-
5
votes1
answer1161
viewsRails and Webmotors
someone with some experience with Rails integration with the Webmotors Api? I am using Gem SAVON to integrate the application with the site API and am getting the error: Savon::Soapfault:…
-
5
votes1
answer188
viewsDefining a tree structure in ruby on Rails
I’m developing a system in ruby on Rails, and I’m stuck on a question. My question is this, I need to create a tree, and then create my 'no' object and I would like it to have a 'no' parent and a…
-
3
votes2
answers1232
viewsEnable CORS in api Rails
They’re using this one GEM to enable the CORS of my application. The code I have in my config/application.rb is as follows: config.middleware.insert_before 0, 'Rack::Cors' do allow do origins…
-
3
votes1
answer126
viewsMultiple submits calling multiple methods in a single form
Hello! I have a form that contains two buttons, each button, when clicking, leads me to a different method within the same controller. How do I do what I need to do? Because I’m not getting it. form…
-
2
votes1
answer240
viewsHow to run Javascript function on the Current page through the Application Controller?
I’m doing a browser validation (IE < 10) through the Application Controller with the gem "browser". I need any application page that is accessed to run a Javascript function with a message saying…
-
2
votes1
answer54
viewsSearch for random objects using conditions
I want to seek for example 10 random people of the same party I did as follows, but this selecting people from all parties, what can be done? = D class Pessoa < ActiveRecord::Base class <<…
-
2
votes2
answers218
viewsAdd new field to the bank with Rails
I inserted a new column in my table contents and also includes the field in the form with the same column name in the creation table (client_id), but this data is not entered when I create a new…
-
2
votes1
answer120
viewsRails 4 Error each_with_index when using activerecord-import
I’m trying to import an app into Rails 4 using Gem activerecord-import. When I try to execute the command: Detail.import( columns, values, :validate => false ,:timestamps => false ) I get a…
-
2
votes1
answer97
viewsDatepicker brings wrong calendar after filling the field
It happens like this: Mum field date, when it is empty, it brings the datepicker correctly and fills the field in the database format aaaa-mm-dd and saved in this format. When I edit, when placing…
-
2
votes4
answers1978
viewsMask in Rails fields
Guys I’m getting beat up for something theoretically simple, I’m wanting to put a date mask on my application.js: //= require maskedinput jQuery(function($){ $("#datadoacao").mask("99/99/9999");…
-
2
votes1
answer817
viewsHow do I make the relationship many for many in Ruby on Rails with has and belongs to Many?
I have a table system and a table category, a system has many categories and a category has several systems, I wanted to use the has_and_belongs_to_many option of Rails (for being a simple relation…
-
2
votes1
answer135
viewsDevise multiple login pages!
I am using Devise to perform my authentication. But I have 3 profile types, and created through the command rails g devise MODEL my users (Admim, dev and manager), but Devise created a login page…
-
2
votes1
answer788
viewsRedirect to another action from another controller in Rails
I am developing a simple action, when saving a register if there is value in a given field the system should redirect to a create from another model/controller. I’m having trouble making this happen…
-
2
votes1
answer41
viewsRails - Relationship BD
I have a table user, where I have a mandatory field cidade, and I have a table contatos (that is belongs_to: user), but the form does not have the field cidade which is mandatory to user. How do I…
-
2
votes1
answer747
viewsHow do I get the value of a hash in Rails?
I have some checkboxs inside a form in the view, which values are being sent to the controller by params to the index. obs. I’m sending the checkbox values from the view index to itself, I need the…
-
2
votes0
answers83
viewsnested Attributes through
I have 3 models: class Day < ApplicationRecord belongs_to :goal has_many :day_salesmen, dependent: :destroy has_many :salesmen, through: :day_salesmen validates_presence_of :date_day, :goal_id…
-
1
votes3
answers169
viewsConditional relationships
I need your help I have following model: class User < Ac... enum user_type: [:normal, :admin] end And I also have the model "Department": class Department < A.... end What I need to do is make…
-
1
votes1
answer112
viewsNested Resources Rails
I created two models in the Rails application, and made their relationship through the declaration in the classes and in the bank as well. I added the configuration to enable nested Resources in the…
-
1
votes1
answer86
viewsRegister two separate models in one
Today I come with another question, but about code. Next, I am making a system to register students and courses and a screen to register classes where part of the registration is to select students…
-
1
votes1
answer233
viewsHow to implement attribute login from another table with Devise in Rails 4?
I currently have a Model User who has a relationship has_one with Customer. In the tables customers have the field CPF that the user informs when to register. I need to implement a login in which…
-
1
votes1
answer142
viewsHow to join 4 tables in SQL that is returning empty ? (Inner, Outer or left Join )
I have 4 tables with the following relationships: Products has N Variations Sizes has N Variations Colors has N Variations Variations belongs to Products,Sizes and Colors The structure of the tables…
-
1
votes1
answer54
viewsPerform searches using repetitions
I created the following method to fetch random people from a certain party, the problem is that if I want to add ten more people from another party it does not add, only replaces the search without…
-
1
votes1
answer123
viewsSelect sex with Enum
I made the field select sex that way: model: enum sexo: [:feminino, :masculino, :desconhecido] def self.sexes_for_select sexos.keys.map{ |x| [x.humanize, x] } end form: <%= f.select :sexo,…
-
1
votes1
answer20
viewsproperty Prompt 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] },…
-
1
votes2
answers176
viewsHow to select record by position
can you tell me how I can select a record by position? How would you search for Maria’s record? Obs: do not search by id or name I found the take in the guide, but it looks for the first and the…
-
1
votes3
answers295
viewsDisplay 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 it in a view and I don’t know how to display the specified fields. In products_controller I have:…
-
1
votes1
answer84
viewsRelationship 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…
-
1
votes0
answers51
viewsrqrcode_png Rails controller - Passing the string contained in the database by parameter
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 found in the field "codigo" table "mesas" into the space below…
-
1
votes1
answer714
viewsCSV In Ruby - Doubt
Good afternoon guys, I’m having a little trouble 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 called given.txt like…
-
1
votes1
answer75
viewsCoffeescript 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">…
-
1
votes3
answers146
viewsViews specifies for Devise
In my project I am using the Rails 5.1.1 and the Devise for login. My question is how I can make a View ,so that the Devise uses as layout, without being the application.html.erb?…
-
1
votes2
answers66
viewsSymbols on the Rails
After creating a template in Rails it is possible to change the created Symbol? For example I created a template called transaction, Rails creates plural transaction but I would like to change this…
-
1
votes3
answers53
viewsRuby application on Rails
Is there a possibility to change the state of an application Rails, from production to testing ? with the possibility to return to production again
-
1
votes1
answer89
viewsInheritance in Rails
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: PK ID Brand ... And some child classes Printer: ID_EQUIPAMENTO PK…
-
1
votes2
answers47
viewsNull return of an object in the controller - RAILS
Hello! I have the following code snippet from a controller called Productoscontroller: def index @produtos = Produto.all end def gerarlog @produtos.each do |produto| File.open('produtosBD.yml', 'a')…
-
1
votes1
answer61
viewsproblem 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/ Log error Command :: file -b --mime…
-
1
votes1
answer720
viewsHow to make a search field with form_tag in Rails?
Hello! Good afternoon, sir. I am a student of information systems and I am doing a small project where I need to place a form to search for the objects of the model Product that exist in the…
-
1
votes1
answer30
viewsRUBY_ON_RAILS - registrations_controller.Rb - I can’t resolve the user registration permission bug!
Method create: def create # super build_resource(sign_up_params) Permission method: def sign_up_params params.require(:usuario).permit(:nome, :email, :password, :password_confirmation,…
-
0
votes1
answer113
viewsRails 4 + -jquery-datatable + ajax-datatable - Http and Actioncontroller error 406:Unknownformat format json
I was studying Rails and following the tutorial https://github.com/antillas21/ajax-datatables-rails. The tutorial steps were the following, create a datatable that would perform a request via json,…
-
0
votes1
answer170
viewsUpdate stock before saving template with nested_attributes and Gem Cocoon
Friends, I have a form that uses nested_attributes and I use Gem Cocoon. I have 3 models involved. Variation Containing Stock, Order, Containing Order and Parent of Detail Containing Order Detail.…
-
0
votes0
answers336
viewsexample of iugu checkout for Rails does not work
I’m trying to make this example of yugu work: https://iugu.com/referencias/exemplo-de-checkout I have an account in iugu in test mode. I followed the steps of this tutorial, made the necessary…
-
0
votes1
answer34
viewsHow to disable a select associaition from simple form
I have a select Association of the simple form, the value of it passed via controler and I wish that in the form the user did not have the option to select another value. I have tried using…
-
0
votes1
answer62
viewsNested Objects has_one Rails 4
Fala galera, I’m new to Rails and I’m trying to make a crud with two objects , a Project and another Album. Project has_one Album , as a test each one has only one :name as parameter , but I cannot…
-
0
votes2
answers280
viewsList random objects
How could I generate random cars in the following model? it would be better to do this in controller? class Pessoa < ActiveRecord::Base has_many :carros end…
-
0
votes1
answer75
viewsField select duplicating with Chosen-Rails and relationship has Many through
Personal talk, I have a GROUP_TV table and it relates to the City table through has Many through. In the _from.html.erb view of GROUP_TV, I have a collection_select to select as many cities as I…
-
0
votes1
answer47
viewsMultiple Joins with Active record returning null
Friends, I have the following exits from the console (Rails 4.1): Product.all Product Load (0.2ms) SELECT "products".* FROM "products" => #<ActiveRecord::Relation [#<Product id: 4, cod:…
-
0
votes0
answers51
viewsJS only works by updating the page
Click on the button: <td><%= link_to 'simulacao', simulacao_path(simulado) %></td> on the simulation/id page there is another button that requires js, but it only works if I update…
-
0
votes1
answer272
viewsSelect state city rails4
I have a dynamic select of states and cities and my idea is to list the state capital selected first. I have the following code to list the cities but not listing the capital first: @cidades =…
-
0
votes1
answer49
viewsProblem with validates in Rails 4
I have a situation I can’t understand what’s wrong. I have a validation in the model that the console works correctly, but when running through the browser the form does Submit and ignores the…
-
0
votes1
answer330
viewsProblem with nested form has_many through using dynamic form
I have the following problem in a form using has_many through. I have a register where I created dynamic forms. These dynamic forms are inserted in another screen. I’m having difficulty in the…