Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Created August 1, 2017 03:05
Show Gist options
  • Save staycreativedesign/4911d08a7d60329abc89f9d6e9ccd7d0 to your computer and use it in GitHub Desktop.
Save staycreativedesign/4911d08a7d60329abc89f9d6e9ccd7d0 to your computer and use it in GitHub Desktop.
class CreateUser
def initialize(data)
@user_params = data
end
def run!
create_user
end
private
def user_params
@user_params.require(:user).permit(:first_name, :last_name, :email, :password, :team_id, :phone_number, :birthday, :business_industry_id, :business_category_id)
end
def create_user
user = User.new(user_params)
if user.save
#add mailchimp
#add notification
#add job
true
else
false
end
end
end
%h4
Enter your information
= form_for @user do |f|
= f.label :first_name
= f.text_field :first_name
= f.label :last_name
= f.text_field :last_name
%h4 login details into Zooma
= f.label :email
= f.text_field :email
= f.label :password
= f.password_field :password
= fields_for :job do |job|
%h4
Your Employer / Business name
= job.label :employer
= job.text_field :employer
%h4
please select a your business category
= select_tag "business_category", options_from_collection_for_select(BusinessCategory.all, "id", "name"), prompt: "Please select a Business Category"
= select_tag "user[business_industry_id]", options_for_select([])
%h4
Your Employer / Business information
= job.label :adress
= job.text_field :address
= job.label :contact, "Phone number"
= job.text_field :contact
= job.label :address2
= job.text_field :address2
= job.label :city
= job.text_field :city
= job.label :state
= job.select :state, options_for_select(states)
= job.label :zipcode
= job.text_field :zipcode
= submit_tag "Join Bold Networking"
class UsersController < ApplicationController
def new
@user = User.new
@business_categories = BusinessCategory.all
respond_to do |format|
format.html
format.json { render :json => @business_categories }
end
end
def create
@user_creation = CreateUser.new(params).run!
if @user_creation
redirect_to root_path
else
#user field inputs arent saved
@user = User.new # User.new does not save form inputs already entered
render :new
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment