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
-
0
votes1
answer46
viewsHow to test the locals on a render?
I am with the following doubt, I do my tests using Ministest, but I have a problem when testing the locals of a render... I do not know how to test, example: Controller: def salvou…
-
0
votes1
answer131
viewssyntax error, Unexpected ',', expecting ')' - Rails 4
The Rails interpreter is sending me this message in the following line of code: ... <li> <%= form_tag("search", { method: "get", class: "navbar-form navbar-right", role: "search" }) do…
-
0
votes1
answer556
viewsHow to Test Web Service on Ruby on Rails
I’m having the following doubt, I’m making a web-service server with my application ruby-on-Rails, I’m using the gem wash-out, I understood how it works and I was able to put my web-service to run,…
-
0
votes2
answers240
viewsaccepts_nested_attributes_for no Rails 4
Expensive! I’m having a hard time because I’m new in Rails. I am trying to generate a form with two models through Nested Form Rails. It is a simple model. "Motor" has one or more "parts", and…
-
0
votes1
answer243
viewsHow to resolve Activerecord::Statementinvalid: PG::Undefinedtable error in Rails?
I am developing an application in Rails and the following error appears in my bank when I try to perform a rake db:migrate. I already tried to drop the bank and create in sequence, however the same…
-
0
votes1
answer67
viewsDynamic fields using Sinatra
In Rails this is a relatively simple task. But I couldn’t find anything in the Sinatra documentation that said it was possible. I want to add fields to a form dynamically. User clicks on a link and…
-
0
votes1
answer381
viewsCalendar in Rails 4
I would like to create a calendar in Rails 4. I followed some tutorials on the internet, however, I was not successful. I managed to make the calendar in "per month" format through the…
-
0
votes0
answers62
viewsPrivate method error while running NET::HTTP.post_form with Rake
I’m trying to send a request using the NET::HTTP.post_form, but is returning this error: Code: module External module Connection module Export class Hawk require 'net/http' require 'uri'…
-
0
votes1
answer49
viewsGem Strong not installed
I’m having trouble adding a Gem to my project, a Gem Strong Parameters. My version of ruby on Rails eh 4.1.4. I don’t know what’s going on. When I give the Bundle install When I give a Bundle update…
-
0
votes1
answer93
viewsAbstractcontroller::Actionnotfound for the Destroy action
Hello, I have two applications running on Heroku with the same code, only I’m having a little problem with the producing. When trying to make a request, I have the following log:…
-
0
votes1
answer280
viewsDynamic Field Forms in Rails?
For my TCC project, I have the following specification: A user, to register a production item, must inform all its ingredients. To facilitate interaction, I thought of, list all ingredients…
-
0
votes1
answer66
viewsRedis in Rails 4
I have an Item template. Can you store Item.all(Item::Activerecord_relation) in Redis? I tried to do so: $redis = Redis::Namespace.new("suggestme", :redis => Redis.new) $redis.set("itens",…
-
0
votes2
answers443
viewsHow to Best Do Conditional WHERE’s with Activerecord on Rails?
I’m working with JSON on Rails. Imagine the route: # rota: pessoas.json def index @pessoas = Pessoa.all end That’s easy! But if I want to add an optional search by age I would have to have a…
-
0
votes1
answer173
viewsbelongs_to has_many search information in table
I have 2 tables: user and contact, and created a third to connect the two: user_contact: class User < ActiveRecord::Base has_many:user_contacts end class Contact < ActiveRecord::Base…
-
0
votes1
answer125
viewsSidekiq for multiple domains
I have a production server that will contain several clients, and I want to add the sidekiq to manage image processing queues. But, I don’t know how it behaves for multiple domains, that is, each…
-
0
votes0
answers37
viewsError unefined method acts_as_authentic for main:Object
My application worked very well until today, but now when starting it presents this error: unefined error method acts_as_authentic for main:Object Follows my code fromact_as_authentic in the user…
-
0
votes1
answer186
viewscannot load such file -- config/boot (Loaderror) - Redmine ruby
I had Redmine installed on a Ubuntu 12.04 server I decided to upgrade the Redmine to the new version. After following all the steps in this tutorial: http://goo.gl/yI0zE2 I’m getting the error…
-
0
votes2
answers49
viewsHow to use HATBM with multiple models
I’ll have the model Tag he’s gonna have a relationship HABTMwith POSTS. But I want him to have a relationship too HABTM with USERS because my goal is in the future to be able to find posts that have…
-
0
votes1
answer60
viewsDefinition of Wordpress-style roles
I am planning the architecture of a personal project to be implemented using Rails. In it, I wish it was possible to easily modify the access rules of users, as is done in wordpress. I know there is…
-
0
votes1
answer52
viewsPartial does not render with enter using Ajax
I have an ajax that fires when the page loads: /assets/javascript/itens.js: if ($('#content-recommendation').length) { xhr = $.ajax({ url:'/get_recommendations/' + gon.item_id + '.js', type:"get"…
-
0
votes1
answer742
viewsHow to pass parameters dynamically to Rails?
I have a rather complex problem. I need to somehow pass parameters dynamically to params via javascript, to show/hide some fields in a report at the user’s request. Below is a representation of the…
-
0
votes2
answers152
viewsChartkick Problem in a Rails Application
I’m trying to implement the Gem Chartkick in a Rails application, but I’m having a small problem. My application has a relationship between two models: class Animal < ActiveRecord::Base…
-
0
votes1
answer543
viewsHow to perform actions at a given time using Ruby on Rails
In my project I would like to create alerts that run at each given interval or at a certain date, Some way to do, using as little memory as possible?
-
0
votes1
answer186
viewsUsing Ruby on Rails is it possible to perform external functions on the client side?
Example: On the computer that is with the browser accessing the page, with the proper permission, run a function in a DLL installed in it? Complementing: My intention was to use on an intranet, and…
-
0
votes3
answers262
viewsHow to instantiate a model and get its features by its name in Ruby on Rails
Since I have the abstract class User, and its sub-classes Client Employee and Admin, would like to render screens according to the chosen subclass. So: users/_form.html.erb : shall contain a…
-
0
votes1
answer323
viewsRelationships with Rails
I’m doing a small blog in Ruby on Rails, but I’m having problems in the comments part. In controllers/posts/comments_controller.rb I have the following: class Posts::CommentsController <…
-
0
votes1
answer53
viewsHow to use text_field via ajax
I am trying to call via ajax a function in a text_field field, I tried it in two ways: 1 - From Undefined method remote_function error. <%= f.text_field(:data, class: "form-control", :remote…
-
0
votes1
answer51
viewsFirst scaffold error in Ruby
I’m looking to learn how to program in Ruby, I created the app, so I had an error from the beginning, where I had to remove all the HTTPS from the files of the GEMFILE folder, changing all manually…
-
0
votes1
answer34
viewsReceive and convert stream from remote server to string
I am making a script that receives a stream, in hexadecimal format, from a remote server via TCP connection, in order to break its encryption and read an ASCII message that is in it. My goal is to…
-
0
votes1
answer1942
viewsHow do I connect to an existing Rails database?
I wonder if there is how to connect to Postgresql, so I only read the data of the tables that are already created. I am developing an API, which will read in a given database, and return an XML, for…
-
0
votes4
answers1008
viewsError starting Rails Server
I’m trying to start the Rails Server but it is always returning me many errors, one of them was about the Sqlite that already corrected by downloading the Gem and modifying the require_paths no…
-
0
votes1
answer677
viewsDevise - Email confirmation and Forget password? [ email does not send ]
Problem sending Confirmation Email and Password Change Problem After requesting to send the forget password? he keeps carrying it until he gives time out. The creation of the Password exchange token…
-
0
votes2
answers69
viewsRequire files on Seeds.Rb
I need to organize my file Seeds.Rb, so I created a namespace where I will add my ex classes: module Seeds class Apple def self.run puts 'teste' end end end Seeds::Apple.run This works perfectly,…
-
0
votes1
answer121
viewsRemove elements outside the standard deviation
I have the following array [123, 350, 3456, 98] and need to remove items outside the standard deviation as in this case the 3456. I have already calculated the standard deviation as below: class…
-
0
votes0
answers850
viewsI18n Translate Enum
I have an Enum in my model containing the states, and I created a translation for it with I18n but it gives the following error: Translation data {...} can not be used with :Count => 1 My Enum:…
-
0
votes1
answer122
viewsActiverecord Labels using I18n
I have the following code: en.BR.yml activerecord: attributes: city: codigo_municipio: "Código do município" View = label(:city, :codigo_municipio) Expected result: # => <label…
-
0
votes0
answers496
viewsUndefined method 'map' for nil:Nilclass
I’m having this problem if the validator finds an error after submitting the form. I think it might be because my instance variable, @users, is nil? I know it in the controller with before_action,…
-
0
votes0
answers35
viewsProblem with command execution
Currently I am doing some tests with the execution of commands through the mouse and with loops, see below: if $MouseOnEvent == -1 if @teste == 1 print "test" @teste = 0 end end if $MouseOnEvent !=…
rubyasked 9 years, 9 months ago user3571412 187 -
0
votes1
answer52
viewsWhy does this way of using case not work?
I have the following code: def label_file_type(type) label = case type.to_s when ['.jpg', '.jpeg', '.png'].include?(type) then content_tag(:span, 'Imagem', class: ['label', 'picture']) when…
-
0
votes1
answer61
viewsTemplate error no rspec-Rails
I’m using the rspec-Rails to test my application, however while testing a view using Ransak for filters I have the following return error: 1) admin/cities/index renders a list of admin_cities…
-
0
votes1
answer115
viewsDatabase configuration using rspec-Rails
In my spec/rails_helper.Rb I added the following code so that the database was automatically created when running rspec: def database_exists? ActiveRecord::Base.connection rescue…
-
0
votes1
answer70
viewsMake condition within the surrender
I’m learning Ruby and I’m having a question about how to make a if inside the render to display the param only if he exists... Ex: if params[:field] puts 'field' => params[:field], end How do I…
-
0
votes1
answer147
viewsComposite index - M:N in Ruby on Rails
I need to add a double index to the ratio N to N, from the table courses_internships. would be more or less like this: add_index[:course_id, :internship_id]. However, when I created the link table,…
-
0
votes1
answer33
viewsLoad skrollr.init the right way in Rails
I’m using the Skrollr in an application Rails as follows: Gem Utilizado: gem 'skrollr-rails' app/Assets/Javascripts/application.js //= require jquery //= require jquery_ujs //= require turbolinks…
-
0
votes2
answers67
viewsRails does not accept request
I set up a simple API in Rails, it only reads the database, and returns the JSON according to the request. However, I went to test the API, making a request with another device, connected via…
-
0
votes2
answers146
viewsAdvanced query in Ruby On Rails (Activerecord)
I need to make a query for a report more or less like this: Produto.include(:clientes).where('count(produto.id) < cliente.quantidade') In sql would be more or less like this: SELECT C.NOME,…
-
0
votes2
answers1228
viewsChange date format in Rails form
I know there is how to edit in the location, to pass it to the Brazilian format. But I do not know the syntax to change the format in the form: <div class="field"> <p> Garantia…
-
0
votes0
answers131
viewsCode runs in eclipse but not when compiles
I’m creating a mod for Minecraft that uses Jruby to run my scripts within the mod. It runs perfectly in the eclipse, but only in it. If I Compile the mod or rotate by gradlew runClient it does not…
-
0
votes1
answer38
viewscall variables of another definition and continue
I have some variables that repeat a lot and I would like to group them into one definition, to be called by several other definitions. Example: module Andre module Dialogos def self.um puts "estou…
-
0
votes1
answer109
viewsHash inside another Hash always returns empty if no key is used
Well I created a method to group all one user’s commits per month into one Hash: def calculate_month_ranking(commits) rank = Hash.new(Hash.new(0)) commits.each do |commit_yml| commit = YAML.load…
rubyasked 9 years, 8 months ago Luiz Carvalho 3,644