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
<% content_for :form_block do %> | |
<h2 class="mb-4">Log in</h2> | |
<%= form_with( | |
model: resource, | |
as: resource_name, | |
url: session_path(resource_name), | |
data: { controller: 'reset_form', action: 'turbo:submit-end->reset_form#reset' } | |
) do |f| %> | |
<div class="form-group"> |
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
class Users::DeviseController < ApplicationController | |
class Responder < ActionController::Responder | |
def to_turbo_stream | |
controller.render(options.merge(formats: :html)) | |
rescue ActionView::MissingTemplate => error | |
if get? | |
raise error | |
elsif has_errors? && default_action | |
render rendering_options.merge(formats: :html, status: :unprocessable_entity) | |
else |
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
# frozen_string_literal: true | |
class TurboFailureApp < Devise::FailureApp | |
def respond | |
if request_format == :turbo_stream | |
redirect | |
else | |
super | |
end | |
end |
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
require 'rails/generators' | |
class AntennaGenerator < Rails::Generators::NamedBase | |
source_root File.expand_path('../templates', __FILE__) | |
argument :actions, type: :array, default: [], banner: "action action" | |
class_option :skip_routes, | |
type: :boolean, desc: "Don't add routes to config/routes.rb." | |
check_class_collision suffix: "Controller" |
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
<% downcase_class_name = class_name.underscore %><% singularize_class_name = downcase_class_name.singularize %><% if namespaced? -%> | |
require_dependency "<%= namespaced_path %>/api_controller"<% end -%> | |
<% module_namespacing do -%> | |
module V1 | |
class <%= class_name %>Controller < ApiController | |
before_action :authenticate_request! | |
<% actions.each do |action| -%> | |
def <%= action %> | |
<% if action == "index" -%> <%= downcase_class_name %> = <%= class_name.singularize %>.all |
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
namespace :resource do | |
desc 'remove duplicate saved students' | |
task cleanup: :environment do | |
# find all models and group them on keys which should be common | |
grouped_by_foreign_keys = SavedStudent.all.group_by do |model| | |
[model.recruiter_user_id, model.student_profile_id] | |
end | |
# grouped_by_email = Person.all.group_by{|model| [model.email] } | |
# grouped_by_foreign_keys.merge(grouped_by_email).values.each do |duplicates| | |
grouped_by_foreign_keys.values.each do |duplicates| |
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
require 'rails_helper' | |
RSpec.describe 'Answer', type: :request do | |
let!(:student) { create(:student) } | |
let!(:answer) { create(:correct_option_answer) } | |
let!(:question) { answer.question } | |
let!(:section_attempt) { answer.section_attempt } | |
let(:answer_id) { answer.id } | |
describe 'GET /answers/:id' do |
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 RequestHelpers | |
def get_request(path, user: nil, params: {}, options: { auth: true }) | |
get path, params: params, headers: request_header(user, options) | |
end | |
def post_request(path, user: nil, params: {}, options: { auth: true }) | |
post path, params: params, headers: request_header(user, options) | |
end | |
def patch_request(path, user: nil, params: {}, options: { auth: true }) |
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
class DefaultUser | |
attr_reader :params | |
def initialize(params) | |
@params = params | |
end | |
def create | |
User.create(default_user_params) | |
end |