Questions tagged as 'ruby-on-rails'

2
answers

database.yml rails 5

Why do I get an error? I'm doing the deploy for production. thanks database.yml production: adapter: mysql2 encoding: utf8 database: trabajo username: root password: 987654 host: localhost port: 3306...
asked by 16.11.2017 / 18:09
1
answer

request.remote_ip from the model?

How can I get the IP from the model, when I assign it a value that saves only null. Example: class User < ApplicationRecord before_create :asignar_ip def asignar_ip self.ip_inicial = request.remote_ip end end Any i...
asked by 21.11.2017 / 16:30
1
answer

My second answer does not display the arrow up

I have the view show where I show my answers to the questions and can vote for them, for my first answer I display the arrow correctly, but for the second answer or others just display the counter. show.html.erb: <div class="conta...
asked by 30.10.2017 / 04:10
1
answer

Pass the model's hash to the controller

I have a list in the model that basically must decide if a record fulfills a function add 1 to good otherwise add 1 to bad and have those two parameters return them to the controller as a hash. What I do not know is how to get the controller...
asked by 19.09.2017 / 22:38
2
answers

problem with routes?

I have two models, Tarea and Comentario , and the relationship is one to many. This would be the code for my router: Rails.application.routes.draw do resources :tareas do resources :comentarios end root to:'tareas#index'...
asked by 15.08.2017 / 16:58
1
answer

Create 2 references to the same model in another Rails: 4

I have 2 models, one for users and another for articles Users:     id     name     email     password     role Articles:     id     title     body I want my article to have 2 references to my user table, one for the user who cr...
asked by 04.09.2017 / 02:07
1
answer

Handling Exceptions in Rails

How can I do Rails 4 to see the exception captured in my view: rescue Exception => exc # dispone el mensaje de error puts "Error ".concat(exc.message) In the terminal it shows me well, but when I want to pass to the view I can not...
asked by 15.06.2017 / 23:11
1
answer

Update a selectbox using ajax

I'm trying to update a select box after creating a regristro from another controller (called "catgrupo" creating categories), but I'm getting the following error: ActionView::Template::Error (undefined local variable or method 'f' for #<#&l...
asked by 15.01.2017 / 20:13
1
answer

Using an object at a global level Rails

I have created a resource with its respective model and controller, in which I seek to customize the style of the site, in which I modify the value of the attribute and when changing, change the style of certain elements of the site, for example...
asked by 18.12.2016 / 00:33
1
answer

Using Scopes with Ruby on Rails

I need help with a scope, I need to show the products that are not on my list of discounts to add them. I'm trying with this code: scope :without_discount, -> (id_params) {Producto.includes(:detalleld).where.not(:detalleld => { lista...
asked by 13.08.2016 / 05:22