mirror of
https://github.com/wahyd4/ocelots.git
synced 2026-08-09 04:56:21 +10:00
addition and removal of facts for a profile
This commit is contained in:
@@ -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
|
||||
@@ -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
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
class Fact < ActiveRecord::Base
|
||||
attr_accessible :content, :person_id, :person
|
||||
|
||||
belongs_to :person
|
||||
end
|
||||
@@ -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
|
||||
|
||||
@@ -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
@@ -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
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user