This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#No olvides las asociaciones en los modelos | |
class RespondentsController < ApplicationController | |
#info del controlador | |
before_action :find_survey, only: [:create] | |
#info del controller | |
def create | |
@respondent = @survey.respondents.new(respondent_params) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
def distance_of_time_in_words(from_time, to_time = 0, include_seconds = false) | |
from_time = from_time.to_time if from_time.respond_to?(:to_time) | |
to_time = to_time.to_time if to_time.respond_to?(:to_time) | |
distance_in_minutes = (((to_time - from_time).abs)/60).round | |
distance_in_seconds = ((to_time - from_time).abs).round | |
case distance_in_minutes | |
when 0..1 | |
return (distance_in_minutes == 0) ? 'menos de un minuto' : '1 minuto' unless include_seconds |