Questions tagged as 'ruby'

1
answer

Ruby on Rails - undefined method 'errors' for nil: NilClass

I've been trying to insert the alert into a form but I get the following error: undefined method 'errors' for nil:NilClass In my form I make a reference to the error: <%= form_for :exercice do |f|%> <%= render 'erro' %&g...
asked by 13.04.2014 / 21:43
1
answer

Ruby on rails does not write to the database

Good evening, guys! I created a small form with two fields and in the future I intend to expand this form with one or two fields. It happens that the insertion of the data in sqlite is not being done, but it does not give any error. The ap...
asked by 02.08.2014 / 01:21
2
answers

Order by over a Count in another table

I wanted to sort a table of items by counting the positive (other table) ratings for that item. This query will be run in controler : item: index Item: id nome Avaliacao id item_id avaliacao[0 negativo, 1 positivo] For example:...
asked by 09.05.2014 / 03:49
1
answer

Devise with parent user and child user

I have this in my Class User in devise class User belongs_to :parent, :class_name => 'User' has_many :children, :class_name => 'User' ... end What I would like to know is what would be migration of...
asked by 06.05.2014 / 17:12
1
answer

Creating projects in Ruby on Rails

I need to create a system that will be as follows: An ordinary user view page that will access the site with a login and password for your area A page where an X company will check your registered users, add information, etc. A page wher...
asked by 10.02.2014 / 21:12
2
answers

How to create a template from another template?

I have two models. One called User and another called Professional, where: #user.rb class User < ActiveRecord::Base has_one :professional accepts_nested_attributes_for :professional end and #professional.rb class Professional < Acti...
asked by 05.01.2015 / 18:58
1
answer

Unit test in Ruby does not work

I am running a simple unit test and on my machine it does not show whether the test ran successfully or error. My code below should fail. require 'minitest/autorun' class MagicBallTest < Minitest::Test def test_ask_returns_an_answer...
asked by 27.05.2018 / 17:53
1
answer

Undefined method '+' for nil: NilClass - Ruby error

I have the following Ruby codes in three different files. Follow them: programa.rb require_relative "product" require_relative "store" cd = Product.new("CD",20.5) pinico = Product.new("Pinico",30.6) store = [cd,pinico] test = Store.new(...
asked by 03.04.2018 / 14:15
1
answer

How to generate sequential number automatically in Rails?

I am developing a form for registration in a selective process and after the user send the registration data I would like to generate the registration number in the following format: 00012018. I found only one answer to that but it did not work....
asked by 29.05.2018 / 23:32
1
answer

How to display to admin the data specific to each user chosen with rails

In the administrative part that I'm doing, my Admin can see all Subscriptions made by users in a table (this part is working perfectly) My admin controller's code, def index @subs = Subscription.all end Table display code table.table...
asked by 18.04.2018 / 22:34