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
-
2
votes1
answer106
viewsHow to override "create" method from Vise?
Hello, I need to overwrite the "create" method from Windows to make a certain logic before saving the user. However I do not know the path of the stones to make such a change. I already googled but…
-
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
answer152
viewsList has_many Relation Elements :through
I am creating an application and realized a has_many :through relation in my template. So far so good, worked smoothly, saved, edits and deletes. The problem is that I would like to list all the…
-
2
votes2
answers287
viewsChange Login [Gem Devise Ruby On Rails]
Gem Design creates a login system with email and password. How do I change the form of email login to a code, ie instead of the user login by email it enter with a number or name?
-
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
votes1
answer23
viewsSystem of notes [params]
I am creating a system of appointments with clients, projects, activities, professionals and appointments, all parts pass and save correctly, except the part of the launch of the notes. Follow the…
-
2
votes1
answer152
viewsRor - Get controller Strong files inside the Application Controller
I am developing a logging process on my system (Rails 5), more specifically within the application controller. This process is being created there so I can add one before_save us controllers that I…
-
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…
-
2
votes1
answer66
viewsHow to find the number of records of a model?
I created a scaffold called a book and I wanted to create a method to count how many book entries there are in my database and use that result in the controller of another scaffold, called the…
-
2
votes1
answer138
viewsHow to avoid large SELECT memory stocking in Rails?
In the routine I’m developing, I do a simple SELECT in the bank, only in a table: Model.select("id").where(:tipo => 2).find_each do |registro| puts registro.id end But this select returns around…
-
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
votes2
answers493
viewsbelongs_to, has_many
Hello everyone all good? I’m starting on Rails and got a little problem to make a simple web application with: Customer registration (with name and address) Employee register (only with name) Work…
-
2
votes2
answers116
viewsHow to update a CRUD with Scaffold?
I have a system with Ruby and a CRUD has been created via Scaffold and I would like to add some new fields. Because what I found on the internet was using the following command. rails generate…
-
2
votes2
answers252
viewsInterpolate variable name in ruby
Hello, I am developing a test automation where I have a variable that receives dynamic values, according to the test run. In the case of the contents of each element changes according to the…
-
2
votes0
answers127
viewsWhy is the "Rails new" command not creating the MVC skeleton?
Hello, I’m having a problem with Rails, when I run the command rails new nome_do_projeto in the terminal it should create the skeleton of folder MVC and the files containing the dependencies but the…
-
2
votes1
answer23
viewsHow to nest a route
Good afternoon, I have a service order and need to generate a report through it, this report needs to receive the service order number to save in the order_id column. I’m trying to make a nested…
-
1
votes1
answer106
viewsGem will_paginate does not load when deploying to Heroku
Initializing repository, done. Counting objects: 3605, done. Delta compression using up to 4 threads. Compressing objects: 100% (1035/1035), done. Writing objects: 100% (3605/3605),…
-
1
votes2
answers114
viewsError when running implementation test
I use the Travis-Ci (as learning) to better understand about implementation tests. Since the build 14 I have this mistake https://travis-ci.org/luizpicolo/website-ruby-rspec-mongodb/builds/17973711…
-
1
votes1
answer171
views"Sqlite3::Sqlexception: no such table: main.Category" running rake db:migrate with Gem Acestry
I’m having a hard time using Gem Acestry in so far as it says: Add index to Migration: add_index [table], :ancestry (UP) / remove_index [table], :ancestry I’m creating a method called Category and…
-
1
votes2
answers109
viewsIs there a correct place to load native Ruby libraries when using Rails?
In certain functionality of my application, I need to use the "open-Uri" library, which is native to Ruby and does not have a library for Ruby on Rails. I’m using a require "open-uri" where I need…
-
1
votes2
answers118
viewsDeploy with Capistrano - Comando su
I’m using Capistrano to deploy on Amazon. Capistrano + Unicorn + Nginx + Ec2 When I go to deploy:Cold, it gives the following error: servers: ["ec2-xx-xxx-xx-xx.sa-east-1.compute.amazonaws.com"]…
-
1
votes1
answer65
viewsWrite to ruby-on-Rails 3.2
Following the tutorial of railscast to add an image of the site Ravatar I found a lagged information with the updates of Rails. The code to create a default image in case of absence of registration…
-
1
votes1
answer419
viewsRuby on Rails: Rake aborted!
I’m starting in the world of Rails through the book Ruby on Rails - Put your web app on track. After creating a module "users" the guide informs us to add in the migration the following command…
-
1
votes1
answer149
viewsDoes the use of Engines in Rails 4 work the same way as in Rails 3.x?
Through several searches in the last few days regarding modularization of applications with Rails, I found vast material regarding Engines in Rails 3.x, but practically nothing referring to Rails 4.…
-
1
votes1
answer74
viewsHow to create routes, which accepts only allowed values?
How do I make :status accept only allowed values? # routes.rb get '/para_:status(/:opcao1)(/:opcao2)', to: 'search#index', :as => :search Currently :status accepts anything I submit. I wish…
-
1
votes1
answer138
viewsDo not use hidden_field fields in nested forms
I wonder if there’s a better way to work with nested attributes without having to send the id of the parent object through the field hidden_field, I find it unsafe to leave it to the page.…
-
1
votes0
answers156
viewsrespond_to show errors with relationships
My question is only about the architecture of how to return the error to view. Follow the example below: class Pessoa < ActiveRecord::Base belongs_to :responsavel, class_name: 'Pessoa',…
-
1
votes1
answer227
viewsBest way to return data entered by a select of constants
I have a model Usuario and for him I have two constants that define a type for him. To pass this information to a select I have a method types that returns a Array. Ex: #models/Usuario.rb class…
-
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
votes2
answers1254
viewsModel validation when update_attributes in Rails
I want to know how to validate my model for when @model.update_attributes(params) in my controller is called to return a possible error or false that seems to be the default returned by…
-
1
votes1
answer115
viewsHow to redirect to the application folder?
Use the ROR with the Nginx. How do I stop what the nginx redirect to the application folder? Instead of the folder /public.
-
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
answer4028
viewsHow to include Bootstrap source files (Glyphicons) in Rails?
In my Rails applications I usually include Bootstrap manually in the folders: app/assets/stylesheets/lib (CSS) and app/assets/javascripts/lib (Javascript) Everything works perfectly with the…
-
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
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
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
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
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
answer164
viewsGenerate offline Rails application
I have a very simple Rails application, with only one controller and two actions. Basically it’s pages with images, css, and some Java. I would like to generate a version of this application that…
-
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
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
votes2
answers241
viewsActive Record Rails 4
If I have a model Evaluation and I do avaliacaoes = Avaliacao.all and then avaliacoes.where("score = ?", 3). In the first command Rails searches all the ratings, what happens in the second command?…