Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
31 changed files
with
289 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
# Place all the behaviors and hooks related to the matching controller here. | |||
# All this logic will automatically be available in application.js. | |||
# You can use CoffeeScript in this file: http://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
// Place all the styles related to the activities controller here. | |||
// They will automatically be included in application.css. | |||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,76 @@ | |||
class ActivitiesController < ApplicationController | |||
before_filter :authenticate_user!, :except => [:index, :show] | |||
respond_to :html, :json, :js | |||
|
|||
# GET /activities | |||
# GET /activities.json | |||
def index | |||
@activities = Activity.all | |||
|
|||
respond_to do |format| | |||
format.html # index.html.erb | |||
format.json { render json: @activities } | |||
end | |||
end | |||
|
|||
# GET /activities/1 | |||
# GET /activities/1.json | |||
def show | |||
@activity = Activity.find(params[:id]) | |||
|
|||
respond_to do |format| | |||
format.html # show.html.erb | |||
format.json { render json: @activity } | |||
end | |||
end | |||
|
|||
# GET /activities/new | |||
# GET /activities/new.json | |||
def new | |||
@activity = Activity.new | |||
|
|||
respond_to do |format| | |||
format.html # new.html.erb | |||
format.json { render json: @activity } | |||
end | |||
end | |||
|
|||
# GET /activities/1/edit | |||
def edit | |||
@activity = Activity.find(params[:id]) | |||
end | |||
|
|||
# POST /activities | |||
# POST /activities.json | |||
def create | |||
@activity = current_user.activities.build | |||
@activity.task_id = params[:task_id] | |||
@activity.content = params[:content] | |||
@activity.save | |||
respond_with @activity | |||
end | |||
|
|||
# PUT /activities/1 | |||
# PUT /activities/1.json | |||
def update | |||
@activity = Activity.find(params[:id]) | |||
|
|||
respond_to do |format| | |||
if @activity.update_attributes(params[:activity]) | |||
format.html { redirect_to @activity, notice: 'Activity was successfully updated.' } | |||
format.json { head :no_content } | |||
else | |||
format.html { render action: "edit" } | |||
format.json { render json: @activity.errors, status: :unprocessable_entity } | |||
end | |||
end | |||
end | |||
|
|||
# DELETE /activities/1 | |||
# DELETE /activities/1.json | |||
def destroy | |||
@activity = Activity.find(params[:id]) | |||
@activity.destroy | |||
respond_with @activity | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
module ActivitiesHelper | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
class Activity < ActiveRecord::Base | |||
attr_accessible :content, :task_id, :user_id | |||
|
|||
belongs_to :task | |||
belongs_to :user | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,7 @@ | |||
= content_tag_for :li, activity, :class => "activity" do | |||
.icon | |||
%a{:href => ""} | |||
= image_tag activity.user.image ? activity.user.image : "dummy.png", alt: activity.user.name, class: "avatar size128" | |||
%p= nl2br activity.content | |||
- if user_signed_in? && current_user == activity.user | |||
%p= link_to "delete", activity_path(activity), :method => :delete, :remote => true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
<%= form_for(@activity) do |f| %> | |||
<% if @activity.errors.any? %> | |||
<div id="error_explanation"> | |||
<h2><%= pluralize(@activity.errors.count, "error") %> prohibited this activity from being saved:</h2> | |||
|
|||
<ul> | |||
<% @activity.errors.full_messages.each do |msg| %> | |||
<li><%= msg %></li> | |||
<% end %> | |||
</ul> | |||
</div> | |||
<% end %> | |||
|
|||
<div class="field"> | |||
<%= f.label :user_id %><br /> | |||
<%= f.number_field :user_id %> | |||
</div> | |||
<div class="field"> | |||
<%= f.label :content %><br /> | |||
<%= f.text_area :content %> | |||
</div> | |||
<div class="actions"> | |||
<%= f.submit %> | |||
</div> | |||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,2 @@ | |||
$('#<%= dom_id(@activity.task) %> textarea').val("") | |||
$('#<%= dom_id(@activity.task) %> .activities ul').prepend("<%= j(render @activity) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1 @@ | |||
$('#<%= dom_id(@activity) %>').remove().fadeOut() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,6 @@ | |||
<h1>Editing activity</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Show', @activity %> | | |||
<%= link_to 'Back', activities_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,25 @@ | |||
<h1>Listing activities</h1> | |||
|
|||
<table> | |||
<tr> | |||
<th>User</th> | |||
<th>Content</th> | |||
<th></th> | |||
<th></th> | |||
<th></th> | |||
</tr> | |||
|
|||
<% @activities.each do |activity| %> | |||
<tr> | |||
<td><%= activity.user_id %></td> | |||
<td><%= activity.content %></td> | |||
<td><%= link_to 'Show', activity %></td> | |||
<td><%= link_to 'Edit', edit_activity_path(activity) %></td> | |||
<td><%= link_to 'Destroy', activity, confirm: 'Are you sure?', method: :delete %></td> | |||
</tr> | |||
<% end %> | |||
</table> | |||
|
|||
<br /> | |||
|
|||
<%= link_to 'New Activity', new_activity_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,5 @@ | |||
<h1>New activity</h1> | |||
|
|||
<%= render 'form' %> | |||
<%= link_to 'Back', activities_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,15 @@ | |||
<p id="notice"><%= notice %></p> | |||
|
|||
<p> | |||
<b>User:</b> | |||
<%= @activity.user_id %> | |||
</p> | |||
|
|||
<p> | |||
<b>Content:</b> | |||
<%= @activity.content %> | |||
</p> | |||
|
|||
|
|||
<%= link_to 'Edit', edit_activity_path(@activity) %> | | |||
<%= link_to 'Back', activities_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,2 @@ | |||
$('#task_content').val("") | $('#task_content').val("") | ||
$('#<%= dom_id(current_user) %> .backlog ul').prepend("<%= j(render @task) %>").fadeIn() | $('#<%= dom_id(current_user) %> .backlog ul.tasks').prepend("<%= j(render @task) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1 +1 @@ | |||
$('#<%= dom_id(@task) %>').remove().fadeOut() | $('#<%= dom_id(@task) %>').remove().fadeOut() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,2 @@ | |||
$('#<%= dom_id(@task) %>').remove().fadeOut() | $('#<%= dom_id(@task) %>').remove().fadeOut() | ||
$('#<%= dom_id(current_user) %> .done ul').prepend("<%= j(render @task) %>").fadeIn() | $('#<%= dom_id(current_user) %> .done ul.tasks').prepend("<%= j(render @task) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,2 @@ | |||
$('#<%= dom_id(@task) %>').remove().fadeOut() | $('#<%= dom_id(@task) %>').remove().fadeOut() | ||
$('#<%= dom_id(current_user) %> .backlog ul').prepend("<%= j(render @task) %>").fadeIn() | $('#<%= dom_id(current_user) %> .backlog ul.tasks').prepend("<%= j(render @task) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -1,2 +1,2 @@ | |||
$('#<%= dom_id(@task) %>').remove().fadeOut() | $('#<%= dom_id(@task) %>').remove().fadeOut() | ||
$('#<%= dom_id(current_user) %> .backlog ul').prepend("<%= j(render @task) %>").fadeIn() | $('#<%= dom_id(current_user) %> .backlog ul.tasks').prepend("<%= j(render @task) %>").fadeIn() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,11 @@ | |||
class CreateActivities < ActiveRecord::Migration | |||
def change | |||
create_table :activities do |t| | |||
t.integer :task_id | |||
t.integer :user_id | |||
t.text :content | |||
|
|||
t.timestamps | |||
end | |||
end | |||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,9 @@ | |||
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html | |||
|
|||
one: | |||
user_id: 1 | |||
content: MyText | |||
|
|||
two: | |||
user_id: 1 | |||
content: MyText |
Oops, something went wrong.