Skip to content

Instantly share code, notes, and snippets.

@staycreativedesign
Created July 30, 2017 22:15
Show Gist options
  • Save staycreativedesign/42cc91847ff8254eb3ffc8bc00027e10 to your computer and use it in GitHub Desktop.
Save staycreativedesign/42cc91847ff8254eb3ffc8bc00027e10 to your computer and use it in GitHub Desktop.
class UsersController < ApplicationController
def new
@business_categories = BusinessCategory.all
@user = User.new
respond_to do |format|
format.html
format.json { render :json => @business_categories }
end
end
def create
binding.pry
user = User.new(user_params)
if user.save
redirect_to root_path, notice: "You have become a Bold Member"
else
render :new
end
end
private
def user_params
params.require(:user).permit(:first_name, :last_name, :email, :password, :team_id, :phone_number, :birthday, :business_industry_id, :business_category_id, :job_id)
end
end
class Job < ApplicationRecord
has_one :user
end
%h4 login details into Bold Networking
= 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 "user[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 :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 User < ActiveRecord::Base
belongs_to :team
belongs_to :business_industry
belongs_to :job
has_one :business_category, through: :business_industry
has_secure_password
end
create_table "users", force: :cascade do |t|
t.string "email"
t.string "password_digest"
t.string "role", default: "visitor"
t.integer "team_id"
t.integer "business_industry_id"
t.integer "job_id"
t.string "first_name"
t.string "last_name"
t.string "phone_number"
t.date "birthday"
t.index ["business_industry_id"], name: "index_users_on_business_industry_id", using: :btree
t.index ["job_id"], name: "index_users_on_job_id", using: :btree
t.index ["team_id"], name: "index_users_on_team_id", using: :btree
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment