diff --git a/app/controllers/registrations_controller.rb b/app/controllers/registrations_controller.rb index 08429f1..0286699 100644 --- a/app/controllers/registrations_controller.rb +++ b/app/controllers/registrations_controller.rb @@ -5,20 +5,22 @@ class RegistrationsController < Devise::RegistrationsController # before_action :configure_account_update_params, only: [:update] prepend_before_action :authenticate_scope!, only: [:edit_email] - def new build_resource super end - # POST /resource + def create if message = math_check + puts message flash.now.alert = message + build_resource(sign_up_params) + render :new + else + super end - super end - # GET /resource/edit def edit_email build_resource puts "EDIT" @@ -28,17 +30,12 @@ class RegistrationsController < Devise::RegistrationsController build_resource super end - # PUT /resource + def update puts "UPDATE" super end - # DELETE /resource - # def destroy - # super - # end - protected def math_check diff --git a/app/views/devise/registrations/new.html.haml b/app/views/devise/registrations/new.html.haml index 1204781..4d80568 100644 --- a/app/views/devise/registrations/new.html.haml +++ b/app/views/devise/registrations/new.html.haml @@ -5,6 +5,11 @@ html: { class: "bg-white mb-4 px-8 pt-6 pb-8 rounded shadow-md" } , url: registration_path(resource_name) ) do |f| = render "devise/shared/error_messages", resource: resource + .mb-4 + = f.label :name, class: "block font-bold mb-2 text-gray-700 text-sm" + = f.input :name, + placeholder: "Pekka Virtanen", + class: "appearance-none border rounded w-full py-2 px-3 text-gray-700 leading-tight focus:outline-none shadow focus:shadow-outline" .mb-4 = f.label :email, class: "block font-bold mb-2 text-gray-700 text-sm" = f.email_field :email, diff --git a/app/views/members/_form.html.haml b/app/views/members/_form.html.haml deleted file mode 100644 index 1f97f5b..0000000 --- a/app/views/members/_form.html.haml +++ /dev/null @@ -1,26 +0,0 @@ -= form_for @member do |f| - .flex.flex-col - - if @member.errors.any? - #error_explanation - %h2= "#{pluralize(@member.errors.count, "error")} prohibited this member from being saved:" - %ul - - @member.errors.full_messages.each do |message| - %li= message - - .grid.grid-cols-2.m-20.gap-10 - .field - = f.label :name - = f.text_field :name - .field - = f.label :picture - = f.file_field :picture - -if @member.picture - %div.overflow-hidden - .my-5 Currently - = image_tag @member.picture, class: "object-contain h-40" - - .field - = f.label :Bio - = f.rich_text_area :bio - .flex.justify-center.actions - = f.submit 'Save'