addition and removal of facts for a profile

This commit is contained in:
Mark Ryall
2012-09-01 17:13:06 +10:00
parent b3803d27da
commit 36f2276397
7 changed files with 44 additions and 7 deletions
+12
View File
@@ -0,0 +1,12 @@
class FactController < ApplicationController
def create
Fact.create person: current_person, content: params[:content]
redirect_to '/profile#facts'
end
def destroy
fact = Fact.find params[:id]
fact.destroy if fact.person = current_person
redirect_to '/profile#facts'
end
end
+1 -1
View File
@@ -7,7 +7,7 @@ class ProfileController < ApplicationController
def update
process_sc_embed_code @person, @person
if @person.update_attributes params[:person]
redirect_to '/', notice: 'Profile successfully updated.'
redirect_to profile_url, notice: 'Profile successfully updated.'
else
render action: 'edit'
end
+2
View File
@@ -1,3 +1,5 @@
class Fact < ActiveRecord::Base
attr_accessible :content, :person_id, :person
belongs_to :person
end
+1 -1
View File
@@ -14,7 +14,7 @@ html
div.nav-collapse
ul.nav
li
= link_to 'profile', person_url
= link_to 'profile', profile_url
= yield :menu_items
ul.nav.pull-right
li
+22 -2
View File
@@ -1,6 +1,9 @@
a name='general'
h1 General
= form_for @person, html: {class: 'form-horizontal'} do |form|
fieldset
div.span4
div.span6
div.control-group
label.control-label for="person_full_name" Full Name
div.controls
@@ -30,4 +33,21 @@
- if @person.photo?
img src="#{@person.photo :small}"
div.form-actions
= form.submit 'Update Profile', class: 'btn btn-primary'
= form.submit 'Update Profile', class: 'btn btn-primary'
a name='facts'
h1 Facts
div.span6
table class='table-striped'
- @person.facts.each do |fact|
tr
td
p = 'I ' + fact.content
td
= link_to "/fact/#{fact.id}", class: 'd', method: :delete do
i.icon-remove-circle
tr
= form_tag "/fact", class: 'form-inline' do
td
= text_field_tag :content, nil, placeholder: 'I ...'
+4 -1
View File
@@ -3,9 +3,12 @@ Ocelots::Application.routes.draw do
post 'home/verify' => 'home#verify'
get 'person' => 'profile#edit'
get 'profile' => 'profile#edit'
put 'person' => 'profile#update'
post 'fact' => 'fact#create'
delete 'fact/:id' => 'fact#destroy'
get 'teams' => 'teams#index'
post 'teams' => 'teams#create'
get 'teams/:slug' => 'teams#show'
+2 -2
View File
@@ -1778,7 +1778,7 @@ table .span24 {
*margin-right: .3em;
line-height: 14px;
vertical-align: text-top;
background-image: url("../img/glyphicons-halflings.png");
background-image: url("/assets/glyphicons-halflings.png");
background-position: 14px 14px;
background-repeat: no-repeat;
}
@@ -1789,7 +1789,7 @@ table .span24 {
}
.icon-white {
background-image: url("../img/glyphicons-halflings-white.png");
background-image: url("/assets/glyphicons-halflings-white.png");
}
.icon-glass {