Skip to content

Commit

Permalink
CRUDded Events
Browse files Browse the repository at this point in the history
  • Loading branch information
ruprict committed Sep 12, 2011
1 parent 950880e commit 6e4ac84
Show file tree
Hide file tree
Showing 6 changed files with 53 additions and 6 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ log/*.log
tmp/
.sass-cache/
*.swp
*.swo
.DS_Store
24 changes: 22 additions & 2 deletions app/assets/stylesheets/events.css.scss
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
21 changes: 20 additions & 1 deletion app/controllers/events_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
class EventsController < ApplicationController
before_filter :authenticate_user!

def index
@events = current_user.events
end
Expand All @@ -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
10 changes: 7 additions & 3 deletions app/views/events/index.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions app/views/layouts/application.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions spec/factories.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

factory :event do
name "Test Event"
description "This is a Test Event"
user
end

Expand Down

0 comments on commit 6e4ac84

Please sign in to comment.