Questions tagged as 'ruby-on-rails'

1
answer

Consultation about relationship in Ruby on Rails

I'm starting in Rails and I could not find a relationship. I have 3 tables: Video, donations and users. A user can put X videos and each video can have several donations. On video I have the user_id In Donations I have the use...
asked by 31.12.2015 / 08:28
2
answers

Redirecting in Ruby on Rails

I am new to Ruby on Rails and would like to know how I can do to redirect from the% share% action to the% share%. I would like the page "show.html.erb" to be displayed after saving the article created from the page "new.html.erb" .     
asked by 08.11.2016 / 01:52
1
answer

Ruby on rails 4: Render and / or redirect called multiple times in action. using Devise

in my controller registrations_controller.rb in the update method, when you edit and make the changes it does not redirect me to the path I want but it flags me the error: DoubleRenderError Render and / or redirect were called multiple times in...
asked by 17.08.2016 / 19:38
2
answers

Error searching for records by id with friendly_id

I do this in my functions edit, update, destroy @post = Post.friendly.find(params[:id]) if @post.user_id == current_user.id There is some way to optimize and make a single function, before doing it this way: before_action :set_user_post,...
asked by 13.08.2016 / 20:45
1
answer

Validate request_time and delivery_time to be greater than 24 hours, with different models

From the current time, I need to validate that it is greater than 24 hours: hora_pedido is start time. hora_entrega is final time. From the parent model, there is an attribute called hora_pedido ; model: class Re...
asked by 08.06.2017 / 16:44
1
answer

syntax error, unexpected keyword_ensure, waiting at the end of the Ruby And Rails entry

Good afternoon Community, I come with this problem from Ruby & Rails I'm a bit of a rookie in the language and this mistake has me dismayed, The error comes to me in the path app/views/bienvenida/index.html.haml:20 assuming that th...
asked by 06.01.2016 / 23:43
1
answer

When should self be used in a Model in Rails?

Within a Model , when I have a variable write operation in a method, why do I need to add self to work correctly? For example, if I have the following code: class Zombie < ActiveRecord::Base beffore_save :make_rotting d...
asked by 25.01.2017 / 19:54
4
answers

Query databases in ruby on rails

I'm trying to learn rails, and the issue of databases has made it a bit difficult to understand. Create a database by console and subsequent migration, this is supposed to create 3 databases (dev, test and production). But when viewing the bd se...
asked by 03.02.2017 / 15:42
2
answers

Handle date and time with Ruby on Rails

At this moment I am developing my web application, which has competitions. These competitions have, among others, these two fields: -deadline, datetime -finished, booblean First of all, I need to know how I can do so that the user can c...
asked by 15.07.2017 / 12:36
1
answer

render related data

I'm using a query to search for records, I have two tables, one is "sale" and the other is "detallevet" (this refers to the details of the sale) by this query I proceed to do the search of the sales in its corresponding model: def self.busqu...
asked by 28.12.2016 / 16:25