Most voted "ruby" questions
Ruby is a dynamic, interpreted, object-oriented, cross-platform, open-source language created by Yukihiro Matsumoto (Matz) in 1995. The [ruby] tag is for issues related to the Ruby language, including its syntax and its libraries. Specific questions about the Ruby on Rails structure should be marked with [ruby-on-Rails] and not [ruby].
Learn more…679 questions
Sort by count of
-
1
votes1
answer418
viewsActive admin and Devise in the application
In this app I am working in I use active admin and in the application I use Devise. Both use it for login. When I logout the /admin I am redirected to the main screen of the end user that starts…
-
1
votes1
answer796
viewsHow to add values from a column in Ruby/Ror
Loveliness? I’m trying to build an application in Rails. In it I have a resource where users inform the running time related to a category. Well, I need to perform adding up the total column time…
-
1
votes1
answer1012
viewsRuby on Rails - Undefined method `errors' for nil:Nilclass
I have been trying to insert Alert in a form but I have the following error: undefined method 'errors' for nil:NilClass In my form I make a reference to the error: <%= form_for :exercice do…
-
1
votes1
answer96
viewsDevise with parent user and child user
I’ve got it in my Class User in the Vise class User belongs_to :parent, :class_name => 'User' has_many :children, :class_name => 'User' ... end What I’d like to know is what the migration of…
-
1
votes2
answers270
viewsOrder by on a Count in another table
I wanted to sort a table of items by counting the positive evaluations(another table) for that item. This query will be executed in the controler: item action: index Item: id nome Avaliacao id…
-
1
votes1
answer520
viewsModel validation with Scope on Ruby on Rails
Suppose the models: class A < ActiveRecord::Base has_many :bs end class B < ActiveRecord::Base belongs_to :a has_many :cs end class C < ActiveRecord::Base belongs_to :b end If I want an…
-
1
votes1
answer650
viewsDisplay error message correctly
I have this code: flash[:error] = t("errors.messages.restrict_dependent_destroy.many") and the system shows the following error message: Unable to delete the record as it exists %{record} dependent…
-
1
votes1
answer605
viewsRelationship has_and_belongs_to_many Rails 4
I have a model of Item has_and_belongs_to_many :generous and a model Gender has_and_belongs_to_many :items, with this I also have a generous item relationship table(id_item, genero_id). I’m trying…
-
1
votes1
answer146
viewsactiverecord is not saving the relationship
I have a relationship like that in Rails class ReducaoZ < ActiveRecord::Base self.table_name = 'reducaoz' has_many :aliquotas, foreign_key: 'reducaoz_id', class_name: 'Aliquota', dependent:…
-
1
votes1
answer209
viewsUse of Nested Attributes with "has_many through" relationship table
I have the following problem, I have a relationship: class Servidor < ActiveRecord::Base has_many :lotacoes, :through=>:servidor_lotacoes has_many :servidor_lotacoes end class Lotacao <…
-
1
votes2
answers403
viewsAsynchronous Process in Ruby on Rails
I have a process that makes a match between the items[books, movies, music and games] of a particular user on Facebook with the items registered in my database. The problem is that the whole process…
-
1
votes0
answers458
viewsWebservice Server in Rails
Hello, I’m developing a Webservicee server using Gem wash_out (https://github.com/inossidabile/wash_out). On this server I will insert, display, delete and update data (CRUD). It will probably be a…
-
1
votes1
answer566
viewsRuby on Rails read csv file and fill table
I have following table news : create_table "noticia", force: true do |t| t.integer "conteudo_id" t.integer "entidade_id" t.integer "imagem_id" t.string "texto" t.datetime "created_at" t.datetime…
-
1
votes1
answer320
viewsDevise: Edit account without need to confirm password
Hello, this is my problem: I have an application (Rails 4) with the gem 'devise' and gem 'omniauth-facebook'. Who logs in with facebook at the time of editing the account appears error "Current…
-
1
votes1
answer87
viewsHow to use authentication in Sinatra?
What would be the best way to authenticate in applications built with Ruby/Sinatra? Devise I know doesn’t work. I have tried several tutorials with Warden, but the settings are very complex and…
-
1
votes1
answer737
viewsAccessing Rails Link Table Fields
MODIFIED QUESTION: I have an application that has 2 tables: Curso and Cargo and a Third Table curso_cargo that makes the HBTM between them. I would like to know how to access a field of this table…
-
1
votes1
answer363
viewsHow to get related data in Ruby on Rails?
Hello. I have an app where User has_many Status. And Status has_many Likes. How do I get the total amount of Ikes a user has? For example, it has 2 status with 10 Ikes each, which gives a total of…
-
1
votes1
answer141
viewsHistory of editions of a Ruby model on Rails
I would like to know how to create a history with all the edits made in a template, in ruby on Rails.
-
1
votes1
answer68
viewsProblem running test controller in Rails 4
Good afternoon, I generated a scaffold of a class of mine, User example. While running the tests I came across the following failure: Minitest::Assertion: "User.count" didn't change by 1. Expected:…
-
1
votes1
answer629
viewsRuby on Rails does not save to bank
Good night, you guys! I created a small form with two fields and in the future I intend to expand this form with one or two more fields. It happens that the insertion of the data in the sqlite is…
-
1
votes2
answers123
viewsPerformance Improvement - Ruby on Rails
I have 3 tables: [users] 1 ------------- n [valuations] n -------- 1 [items] Where evaluation can be positive(evaluation: true) or negative(assessment: false), i need a method that returns all the…
-
1
votes2
answers220
viewsNomethoderror: Undefined method `similaridade_com' for #<Class:0x007ff55873cad0> - Ror
I’m trying to create an attribute of the class that will be an array of similarities between users. Is there something wrong with this construction? There’s a better way to do it? class Usuario <…
-
1
votes2
answers947
viewsAdd values from a column with Ruby
Hello I’m starting my studies with Ruby On Rails, and I’m making an application that manages expenses. Well what I need to do sum up all the expenses of the "value" column and show in the view. I’m…
-
1
votes2
answers56
viewsMatcher be_true ruby/rspec
I’m starting to study about ruby/rspec by following a book, but I’m not making progress using the matcher be_true. Follow below the error: BagOfWords#push is possible to put words on it (FAILED - 1)…
-
1
votes1
answer196
viewsAlgorithm takes 5sec but the page takes 1.5m to load
After calling a process via ajax if ($('#content-recommendation').length) { $.ajax({ url:'/get_content_recommendation/' + gon.item_id + '.js', type:"get" }); } I do this in…
-
1
votes1
answer4080
viewsHow to make a switch in Ruby?
How can I make a switch in Ruby?
-
1
votes2
answers1488
viewsDifficulty with for loop in Ruby
I’m having trouble dynamically displaying the content of variables. Ex: minha_var_1 = %{Um texto} minha_var_2 = %{Outro texto} minha_var_3 = %{Mais outro texto} But I’ve tried to show off so much…
-
1
votes1
answer51
viewsPower ball in Ruby
I did the following program: class PowerBall def jogo brancas = Array.new 50.times{brancas << false} brancasSorteadas = Array.new 5.times{brancasSorteadas << 0} for x in brancasSorteadas…
rubyasked 10 years, 5 months ago Hugo Rodrigues 11 -
1
votes1
answer80
viewsPelican: How to define the layout of each page similar to Jekyll?
I use Jekyll in my website, I’ll stop using for this reason. I wanted to migrate to the Pelican but I’m stuck in layouts. Here’s the problem: In Jekyll I can on each page (page) define the layout,…
-
1
votes1
answer193
viewsHow to create block helpers in Rails?
I need to create a dropdown menu helper... but I don’t have much idea how to do that. Wanted a block helper, as is done with forms. Ex.: <%= form_for(@teste) do |f| %> <%= f.text_field…
-
1
votes1
answer68
viewsError editing user register with nested_form
I’m having a problem with an app I did here on the job. I use nested_form together with Devise for a student registration, that is, when I register a student, I already add a user to it in the…
-
1
votes1
answer152
viewsREST with problem in CREATE
Introducing I am developing an app and using Rails. $ rake routes POST /companies(.:format) companies#create Routes.Rb resources :companies Problem When I step my object to be inserted using Postman…
-
1
votes2
answers135
viewsHow to create a model from another model?
I have two models. One called User and the other called Professional, where: #user.rb class User < ActiveRecord::Base has_one :professional accepts_nested_attributes_for :professional end and…
-
1
votes1
answer234
views -
1
votes2
answers80
viewsHow to manually delegate an object to Ruby
To better understand the meta-programming in Ruby I would like to make an object, when instantiated, delegate all methods of an object passed as parameter. And your class will pass to delegate the…
-
1
votes1
answer82
viewsAdding features to a Model that depend on the Controller or View
I would like to add the following methods to my Models when presented in the View, for example, can_be_showed, can_be_edited, can_be_destroyed, among others, but in some cases these methods may…
-
1
votes1
answer85
viewsUsing Jekyll to create a news for
I’m having the following doubt as I create a news for? I have to add something inside the config.yml file? Inside the _post folder I have the file 2015-03-03-Welcome-Jekyll.markdown --- layout: post…
-
1
votes1
answer287
viewsWhy is the translation path not being found?
Assuming my yml file is arranged that way: pt-BR: alert_system: schedules: teste: 'ss' every: 'Todo Dia:' each: 'A Cada:' each_day: 'A Cada #{dias} Dias' on: 'Na data:' When calling from within a…
-
1
votes1
answer304
viewsfreight couriers
Hello, I am using this calculation in the controller but when I put <%= @pac %> or <%= @sedex %> in the view is not showing the value, someone is having the same problem? grateful def…
-
1
votes1
answer108
viewsHow to model a comment system
I am developing an application in Rails. I would like to know how to model the comments part. There is a table for the calls( Helpdesk system ), and the same relates to the history table, which are…
-
1
votes1
answer73
viewsAdd method to Activerecord::Base
I created a method in the Activerecord::Base and it uses another method to be defined in the model, I need to validate if the model method is defined before executing what I need, but it says it’s…
-
1
votes1
answer70
viewsHow to leave this DRY code block in Ruby
I got this code pad right here: if contract.amendments.empty? if Date.today - contract.due_date >= 30 || Date.today + contract.due_date <= 30 @start_date = contract.due_date + 1 @end_date =…
-
1
votes1
answer886
viewsHow to allow only the administrator to register a user with Devise
I wanted to know if there is only the administrator register user, with Devise. I can not program this. And where is the controller with the Devise methods in the project?
-
1
votes1
answer75
viewsHow to send errors and exceptions to the main output?
I’m using Ruby 2.1 32 bits. Interpreting scripts as CGI by Apache 2. Through Local IP. I am in a process of migrating several script in PHP to Ruby. During the process of writing code, several times…
-
1
votes1
answer289
viewsExtract hash in Ruby on Rails
I got the following Hash my_hash = {city: {id:1, created_at: '', name: 'test_city'}, uf: {id:1, created_at: '', name: 'test_uf'}} I need to extract some data from it ex: my_hash.extract!({city:…
-
1
votes0
answers38
viewsRuby Winapi Socket TCP/IP
Hello, Currently I need to create a ruby connection using winapi only. Everything works perfectly, however, when the client sends an information, it needs EXACTLY ONE ANSWER, if there is no answer…
-
1
votes2
answers162
viewsProblem when rendering partials dynamically
I have the following code: <table class="table table-bordered table-striped" border="0"> <% @time_line.each do |time_line| %> <%= render partial: partial_name( get_type(time_line) ),…
-
1
votes0
answers31
viewsRails Form Builder is not rendering all content
I created a select with form Builder, but it doesn’t render all the content inside it def select_box(name, value, select_options = {}, html_options = {}) content_tag :div, class: class_name do…
-
1
votes1
answer46
viewsExport from SQL to Excel and perform Download Syntax error: Unexpected ',', expecting end-of-input
I made this Query MtDispositivo.where("id_conta = 28 or id_conta = 29 or id_conta = 30 or id_conta = 36") This Query returns me all accounts containing the Ids: 28, 29, 30 and 36. Could you give me…
-
1
votes1
answer554
viewsDoubt about relationship between Rails tables
Hello, I’m a beginner in Rails, (setting up my first system) and I have two questions about relationship between tables: 1.) I have a model Row with the attributes origin and fate which shall refer…