Permalink
Browse files

CRUDded Events

  • Loading branch information...
1 parent 950880e commit 6e4ac84c01885fce51a3366c8cb2352efc35c386 @ruprict committed Sep 12, 2011
View
@@ -4,4 +4,5 @@ log/*.log
tmp/
.sass-cache/
*.swp
+*.swo
.DS_Store
@@ -5,9 +5,29 @@
#map {
height: 350px
}
-.new_event label, input[type='text'] {
- display:inline;
+.new_event, .edit_event {
+ label,input[type='text']{
+ display:inline;
+ }
}
+
input#event_description {
width: 500px;
}
+.selected {
+ background-color: #C66660;
+ color: #f2efe8;
+}
+.del_form div {
+ float:left;
+}
+.del_form input {
+ width: 20px;
+ height: 20px;
+ margin-right: 20px;
+ background: red;
+ color: white;
+ line-height:10px;
+ margin-bottom: 0px;
+ padding: 2px;
+}
@@ -1,5 +1,6 @@
class EventsController < ApplicationController
before_filter :authenticate_user!
+
def index
@events = current_user.events
end
@@ -9,6 +10,24 @@ def create
event.save
redirect_to events_path
end
-
+
+ def edit
+ @events = current_user.events
+ @event = @events.find(params[:id])
+ render 'index'
+ end
+
+ def update
+ event = current_user.events.find(params[:id])
+ event.update_attributes(params[:event])
+ event.save
+ redirect_to events_path
+ end
+
+ def destroy
+ event = current_user.events.find(params[:id])
+ event.destroy
+ redirect_to events_path
+ end
end
@@ -2,10 +2,14 @@
#map.sixteen_columns
%ul#events
- for event in @events
- %li
- %span.event_name= event.name
+ %li{:class => @event == event ? :selected : nil}
+ %span.del_form
+ =button_to "X", event, :confirm => "Are you sure?", :method => :delete
+ %span.event_name
+ = link_to event.name, edit_event_path(event)
%span.event_description= event.description
-= form_for Event.new do |f|
+ %div.clear
+= form_for @event || Event.new do |f|
= f.label :name
= f.text_field :name
= f.label :description
@@ -30,6 +30,8 @@
-if user_signed_in?
Hullo #{current_user.name}
|
+ = link_to "My Events", user_root_path
+ |
= link_to "Sign Out", destroy_user_session_path, :method => :delete
- else
= link_to "Sign In", new_user_session_path
View
@@ -9,6 +9,7 @@
factory :event do
name "Test Event"
+ description "This is a Test Event"
user
end

0 comments on commit 6e4ac84

Please sign in to comment.