Skip to content

Instantly share code, notes, and snippets.

@Frank004
Created July 27, 2016 21:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Frank004/69e51cb822bbbf9db1eb6ec5666c8c6e to your computer and use it in GitHub Desktop.
Save Frank004/69e51cb822bbbf9db1eb6ec5666c8c6e to your computer and use it in GitHub Desktop.
class SurveyTransController < ApplicationController
skip_before_filter :authenticate_user!
layout "survey"
def survey
end
def password_confirmation
# if params[:password_confirmation].present? && params[:survey_id].present?
@survey = Survey.find_by_id(params[:survey_id])
if @survey.present? && @survey.password == params[:password_confirmation]
session[:current_survey_id] = @survey.id
redirect_to :survey_form_section
else
flash[:notice] = "Datos incorrectos. Favor verifique sus datos."
redirect_to :survey
end
# else
# flash[:notice] = "No pueden estar vacios."
# redirect_to :survey
# end
end
def survey_form_section
unless session[:current_survey_id].nil?
@survey = Survey.find_by_id(session[:current_survey_id])
@project= @survey.project
# despues de completar el form
# redirect_to :survey_form
else
redirect_to :survey,
notice: 'No tiene acceso a esta section. Favor entrar credenciales.'
end
end
def survey_form
unless session[:current_survey_id].nil?
@survey = Survey.find_by_id(session[:current_survey_id])
@anwser = @survey.anwsers.new(answer_params)
@anwser.section_id = params[:section]
else
redirect_to :survey,
notice: 'No tiene acceso a esta section. Favor entrar credenciales.'
end
end
def survey_proccess
end
def survey_finish
end
private
def answer_params
params.require(:answer).permit()
end
end
get '/survey', to: 'survey_trans#survey', as: :survey
get '/password_confirmation', to: 'survey_trans#password_confirmation', as: :password_confirmation
get '/survey_form_section', to: 'survey_trans#survey_form_section', as: :survey_form_section
get '/survey_form', to: 'survey_trans#survey_form'
post '/survey_form', to: 'survey_trans#survey_form'
get '/survey_finish', to: 'survey_trans#survey_finish', as: :survey_finish
<div class="well profile box col-lg-5 col-lg-offset-3">
<div class="row">
<div class="col-md-12">
<h1>Contraseña de Confirmación</h1>
<hr />
<%= form_tag({controller: "survey_trans", action: "password_confirmation"}, {method: :get}) do %>
<div class="form-group">
<%= text_field_tag :survey_id,nil, class: "form-control", placeholder: "Encuesta",maxlength: 10 %>
<span class="help-block">"Número de encuesta".</span>
</div>
<div class="form-group">
<%= password_field_tag :password_confirmation,nil, class: "form-control", placeholder: "contraseña",maxlength: 10 %>
<span class="help-block">"contraseña para poder llenar encuesta".</span>
</div>
<button class="btn btn-success ladda-button" data-style="zoom-out" type="submit">
<span class="ladda-label">Confirmar</span>
<span class="ladda-spinner"></span>
</button>
<%=link_to "Form Section", survey_form_section_path, class: "btn btn-warning"%>
<% end %>
</div>
</div>
</div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment