diff --git a/app/controllers/profiles_controller.rb b/app/controllers/profiles_controller.rb index bd2547a..e0d7afb 100644 --- a/app/controllers/profiles_controller.rb +++ b/app/controllers/profiles_controller.rb @@ -1,15 +1,46 @@ class ProfilesController < ApplicationController + def index + @profiles = User.where(public: true) + end + + def show # include MD5 gem, should be part of standard ruby install # require 'digest/md5' - + if params[:id].nil? + @profile = current_user + else + @profile = User.find(params[:id]) + end + # get the email from URL-parameters or what have you and make lowercase - email_address = current_user.email.downcase - + email_address = @profile.email.downcase + # create the md5 hash hash = Digest::MD5.hexdigest(email_address) - + # compile URL which can be used in + +<% if @profile.errors.any? %> +
+

+ <%= pluralize(@profile.errors.count, "error") %> prohibited + this article from being saved: +

+ +
+ <% end %> +

+ <%= f.label "Required Fields*" %>
+

+ +

+ <%= f.label "First Name *" %>
+ <%= f.text_field :first_name %> +

+ +

+ <%= f.label "Last Name *"%>
+ <%= f.text_field :last_name %> +

+ +

+ <%= f.label "Email" %>
+ <%= f.text_field :email %> +

+ +

+ <%= f.label "About Me" %>
+ <%= f.text_area :blurb %> +

+ +

+ <%= f.label "My Hobbies" %>
+ <%= f.text_area :hobbies %> +

+ +

+ <%= f.label "My Projects" %>
+ <%= f.text_area :projects %> +

+ +

+ <%= f.label "Preferred Method of Contact" %>
+ <%= f.text_area :contact %> +

+ +

+ <%= f.label "Check the box to Make Your Profile Public:" %> + <%= f.check_box :public %> +

+ +

+ <%= f.submit "Update" %> +

+ +<% end %> diff --git a/app/views/profiles/edit.html.erb b/app/views/profiles/edit.html.erb new file mode 100644 index 0000000..13f2433 --- /dev/null +++ b/app/views/profiles/edit.html.erb @@ -0,0 +1,5 @@ +

Edit Your Profile

+ +<%= render 'form' %> + +<%= link_to 'Back' , profile_path %> diff --git a/app/views/profiles/index.html.erb b/app/views/profiles/index.html.erb new file mode 100644 index 0000000..b7f2f62 --- /dev/null +++ b/app/views/profiles/index.html.erb @@ -0,0 +1,13 @@ +

Current Members

+ + + + + + + <% @profiles.each do |profile| %> + + + + <% end %> +
Name
<%= link_to profile.first_name + ' ' + profile.last_name, controller: "profiles", action: "show", id: profile %>
diff --git a/app/views/profiles/show.html.slim b/app/views/profiles/show.html.slim index ec79142..08512d8 100644 --- a/app/views/profiles/show.html.slim +++ b/app/views/profiles/show.html.slim @@ -1,3 +1,49 @@ + h1.page-header Profile = image_tag @gravatar_src, class: "gravatar" -| #{current_user.email} + + +p +
+
First Name:
+
#{@profile.first_name}
+
Last Name:
+
#{@profile.last_name}
+
Email:
+
#{@profile.email}
+
+p +p +
+
About Me:
+
#{@profile.blurb}
+
+p +
+
Hobbies:
+
#{@profile.hobbies}
+
+ +
+
Projects:
+
#{@profile.projects}
+
+ +p +p +
+
Preferred Method of Contact:
+
#{@profile.contact}
+
+p +
+- if @profile.public +
Privacy Preference: Viewable to Public
+- else +
Privacy Preference: Private
+
+ + = link_to 'Back', profiles_path +p +-if current_user and @profile.id == current_user.id + = link_to 'Edit Profile', edit_profile_path diff --git a/config/routes.rb b/config/routes.rb index 70b37f0..4d42ea0 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,6 +1,7 @@ Capacitor::Application.routes.draw do devise_for :users resource :profile + resources :profiles resources :charges resource :membership root 'home#index' diff --git a/db/migrate/20150702002729_add_profile_information_to_users.rb b/db/migrate/20150702002729_add_profile_information_to_users.rb new file mode 100644 index 0000000..20e191b --- /dev/null +++ b/db/migrate/20150702002729_add_profile_information_to_users.rb @@ -0,0 +1,11 @@ +class AddProfileInformationToUsers < ActiveRecord::Migration + def change + add_column :users, :first_name, :string + add_column :users, :last_name, :string + add_column :users, :blurb, :text + add_column :users, :hobbies, :text + add_column :users, :projects, :text + add_column :users, :contact, :string + add_column :users, :public, :boolean + end +end diff --git a/db/schema.rb b/db/schema.rb index e18d865..fb85358 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -11,7 +11,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20141024093025) do +ActiveRecord::Schema.define(version: 20150702002729) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" @@ -46,6 +46,13 @@ t.datetime "updated_at" t.string "stripe_customer_id" t.integer "role_id" + t.string "first_name" + t.string "last_name" + t.text "blurb" + t.text "hobbies" + t.text "projects" + t.string "contact" + t.boolean "public" end add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree