Most voted "ruby-on-rails" questions
Ruby on Rails is an open source web development framework written in Ruby. Allows the developer to write source code following the MVC model and is known for its "convention on configuration" approach to application development.
Learn more…779 questions
Sort by count of
-
1
votes3
answers332
viewsIs it recommended to test model validations?
My experience is with Ruby on Rails, but I believe my question will be for other cases. The ORM Activerecord (from Rails) allows validating in fields things like: Presence Oneness Size (of a string)…
-
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
votes3
answers160
viewsbg-image internationalization by CSS
I have a Rails project that needs different images for each language, however and image is pulled from CSS and I can’t change that. How to change the image according to the chosen language?…
-
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
answers245
viewsShow error in field instead of flash/notice
I have a Rails application with Twitter Bootstrap that, when creating a record and presenting errors, shows the error in a flash/notice as per image: However, I would like errors to appear in the…
-
1
votes1
answer401
viewsHumanize in accented characters
I have the following problem, I have some error messages in my system, but when there are accents in the messages, humanize does not apply to these characters, I tried to use the gem…
-
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
votes1
answer84
viewsSimple_form disabling selection item according to registration situation
I have a f.association that brings all registered customers. In the client I have a field status. I wish that when the status is false, client appears in select box, but is not selectable, this is…
ruby-on-railsasked 10 years, 1 month ago Adell 133 -
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
answer225
viewsAutomatically bring data with Associations
I have two models cliente.rb and atendimento.rb, both already with their Associations. When will I generate a new service with you through collection_select select the name of the customer, the…
ruby-on-railsasked 10 years, 1 month ago Diogenes 19 -
1
votes1
answer43
viewsHow to deal with the requirement of certain attributes in models that include a Concern in Rails?
I’m working on a project where I have several models who share the behavior of being approvable. After doing some research, I came to the conclusion that the best thing in this case is to use the…
-
1
votes1
answer696
viewsAfter renaming a field in a table, how do I update the entire Rails project?
I used Scaffold to generate a small project, then I changed the name of a field into a table, (something that’s rare but happens in real life), how do I update the whole project? P.S.: Rake…
ruby-on-railsasked 9 years, 12 months ago herculano 23 -
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
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
answer205
viewsBypass FTP lock
Hello! I need to import a . zip file from a Brazilian FTP server. It works perfectly on my development machine, both using Ruby native Net/Ftp and using Linux wget, the problem is it doesn’t work on…
-
1
votes2
answers971
viewsi18 - How to translate attributes in error messages
Friends I have something like this: user.Rb: class User < ActiveRecord::Base has_one :address, autosave: true, dependent: :destroy accepts_nested_attributes_for(:address, update_only: true,…
-
1
votes1
answer105
viewsSearch using Solr in Rails
If I search for a piece of a word other than the first characters of the word he doesn’t think. Like if I search for "Car" it searches correctly, but now if I search for "los" or "arlos" returns me…
-
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
votes2
answers199
viewsConstruct an unordered list with content_tag
How to build a list containing sublists using the content_tag rails? Using the method in the Helper does not work. <ul class="menu"> <li>Item1 <ul> <li><a…
-
1
votes0
answers56
viewsRuby Adwords API returning Authenticationerror.OAUTH_TOKEN_HEADER_INVALID
I’m using: gift omniauth omniauth-google-Oauth2 google-Adwords-api and catch the token by the callback of the oauth: class OmniauthCallbacksController < Devise::OmniauthCallbacksController def…
-
1
votes1
answer109
viewsUsing Strong Attributes with Rails 4 and has_one relationship
I have a relationship has_one similar to its where a :person has a :address. It turns out that the relationship is generated but the street that I put in input :street (address attribute) is not…
-
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
answer107
viewsProblem generating a Ruby on Rails app
When trying to create a Ruby On Rails application this happened; I tried to get around like this; how to solve this?…
ruby-on-railsasked 9 years, 9 months ago wladyband 4,694 -
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
votes2
answers686
viewsRails 4 translated error messages, change model name and attributes
Hello, I’m starting in Rails and I’m picking up to handle error messages in en-BR. I am using Mongodb/Mongoid for the database layer. I own a model user, with attributes name, email and password. I…
-
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
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
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
answer100
viewsFails when I make Bundle install
Good afternoon, I have a little problem when I do bundle install: /usr/local/bin/ruby extconf.rb *** extconf.rb failed *** Could not create Makefile due to some reason, probably lack of necessary…
-
1
votes1
answer112
viewsI want to select a specific value in the collection_select, how do I?
Good morning, I’m working with Ruby on Rails and I’m having a little trouble. I have a value in a @n variable, and I have a collection_select that will fetch me all the values of a collection. what…
ruby-on-railsasked 9 years, 8 months ago Catarina 67 -
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
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
answer49
viewsSVG image conversion in Ruby on Rails
I have an application in Rails and there I generate SVG images to return to the user by email, but I want to return this in another format (png or jpg). Does anyone have any tips on how I can do…
-
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
answer50
viewsDuplicate a ruby membership on Rails
I’m having a doubt. I send the table I already made, but I have a problem in the case of "Isolate's name" "catx" have two "gene's name" associado, "catxx" e o "catxxx", but I’m putting the two in…
ruby-on-railsasked 9 years, 7 months ago Catarina 67 -
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
votes1
answer145
viewsHow to customize Ruby tags on Rails?
I have a form: <% form_tag :action => 'validacao' do %> <p> Login: <%= text_field :acesso, :email %></p> <p> Senha: <%= password_field :acesso, :password…
-
1
votes1
answer228
viewsDoubt in Creating an app / Server / Notifications
I am with a project to develop an Android app, using Phonegap + jQueryMobile, I have already managed to create the interface, change screens and etc. Now comes the hard part for me: the Backend :( I…
-
1
votes1
answer122
viewsUse of STI(Single Table Inheritance) on Rails
Assuming a project in Rails with the models Livestock, Agriculture, Piscicultura e Benfeitoria. These inherit the properties of a model called Activity and are considered types of activity. Models…
-
1
votes2
answers1520
viewsHow to model with inheritance a structure of People?
Hi, I’m having a hard time doing my Pessoa modeling. Theoretically it seems a very simple thing, but I can’t find a way to follow, say, "good programming practices". My problem is this: In my system…
-
1
votes0
answers46
viewsSkroll Stylesheet not working
I have the following code: Gem: gem 'skrollr-rails' Javascript: //= require jquery //= require jquery_ujs //= require turbolinks //= require skrollr //= require skrollr.menu //= require…
ruby-on-railsasked 9 years, 6 months ago Daniel 1,222 -
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
answers312
viewsHow to upload files?
Well friends, I have to upload pdf files (and only in this format) and link to a user. How could I do that? What is the best way to structure the files saved on the server?
ruby-on-railsasked 9 years, 6 months ago Jedaias Rodrigues 6,718 -
1
votes1
answer79
viewsHow to make a Seed.Rb by randomly searching Sqlite data in Rails?
Since I already have a register of cities and states, which you can see below, my question is the following, how can I place within the function 10.times in the lines of address_city and…
-
1
votes1
answer465
viewsError rake db:create
Good afternoon, I am using someone else’s program developed in Ruby on Rails and after giving bundle install in the project folder and install all gems, I tried to create the database through the…
ruby-on-railsasked 9 years, 5 months ago Pedro Luiz Tortella 57 -
1
votes1
answer52
viewsRuby on Rails problem 3.2 - It shows in HTML Git commands
When I push to the server (I’m using Jenkis and gitlab ) when I check the address it shows several errors. www.scti.uenf.br this is the site that is in trouble. Ruby 1.8.2 Rails 3.2 Jenkins Gitlab…