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
32 changed files
with
190 additions
and
117 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
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 | 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 | 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the comment controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
2 changes: 1 addition & 1 deletion
2
app/assets/stylesheets/home.css.scss → app/assets/stylesheets/story.css.scss
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
// Place all the styles related to the home controller here. | ||
// Place all the styles related to the story 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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
class CommentsController < ApplicationController | ||
load_and_authorize_resource :story | ||
|
||
def create | ||
@comment = Comment.new(params[:comment]) | ||
@comment.user = current_user | ||
@comment.story = @story | ||
if @comment.save | ||
redirect_to @story | ||
else | ||
render :new | ||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
class StoriesController < ApplicationController | ||
load_and_authorize_resource | ||
|
||
def index | ||
# @stories = Story.all | ||
end | ||
|
||
def new | ||
@story = Story.new(params[:story]) | ||
end | ||
|
||
def create | ||
@story = Story.new(params[:story]) | ||
@story.user = current_user | ||
if @story.save | ||
redirect_to @story | ||
else | ||
render :new | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module CommentHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module StoryHelper | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
class Ability | ||
include CanCan::Ability | ||
|
||
def initialize(user) | ||
|
||
can :read, Story | ||
can :create, Story | ||
|
||
can :read, Comment | ||
can :create, Comment | ||
|
||
# Define abilities for the passed in user here. For example: | ||
# | ||
# user ||= User.new # guest user (not logged in) | ||
# if user.admin? | ||
# can :manage, :all | ||
# else | ||
# can :read, :all | ||
# end | ||
# | ||
# The first argument to `can` is the action you are giving the user permission to do. | ||
# If you pass :manage it will apply to every action. Other common actions here are | ||
# :read, :create, :update and :destroy. | ||
# | ||
# The second argument is the resource the user can perform the action on. If you pass | ||
# :all it will apply to every resource. Otherwise pass a Ruby class of the resource. | ||
# | ||
# The third argument is an optional hash of conditions to further filter the objects. | ||
# For example, here the user can only update published articles. | ||
# | ||
# can :update, Article, :published => true | ||
# | ||
# See the wiki for details: https://github.com/ryanb/cancan/wiki/Defining-Abilities | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Comment < ActiveRecord::Base | ||
belongs_to :user | ||
belongs_to :story | ||
|
||
validates :user, :story, :body, presence: true | ||
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
class Story < ActiveRecord::Base | ||
belongs_to :user | ||
has_many :comments | ||
|
||
validates :user, :title, :body, presence: true | ||
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 was deleted.
Oops, something went wrong.
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
- @stories.each do |story| | ||
%article | ||
%h3= link_to story.title, story | ||
.author= story.user | ||
.created= story.created_at | ||
|
||
- unless @stories.any? | ||
%h3 No Stories have been uploded |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
= form_for(@story) do |f| | ||
.field | ||
= f.text_field :title, placeholder: 'Title' | ||
.field | ||
= f.text_area :body, placeholder: 'Body Text' | ||
%div | ||
= f.submit |
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 | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
%h3= @story.title | ||
.posted | ||
%b Posted By: | ||
%span.author= @story.user | ||
( | ||
%span.created= @story.created_at | ||
) | ||
|
||
.body= @story.body | ||
|
||
.comments | ||
= form_for([ @story, @comment ||= Comment.new(params[:comment]) ]) do |f| | ||
.field | ||
= f.text_area :body, placeholder: 'Body Text' | ||
%div | ||
= f.submit | ||
|
||
- @story.comments.each do |comment| | ||
.comment | ||
.author= comment.user | ||
.created= comment.created_at | ||
.body= comment.body | ||
|
||
- unless @story.comments.any? | ||
%b No Comments have been posted | ||
|
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 | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,15 @@ | ||
StoryShare::Application.routes.draw do | ||
|
||
match '/', :controller => :home, :action => :index | ||
match '/', :controller => :stories, :action => :index | ||
root :to => 'stories#index' | ||
|
||
devise_for :users, :controllers => { :omniauth_callbacks => "users/omniauth_callbacks" } do | ||
delete '/users/disconnect/:provider', | ||
:to => 'users#disconnect_omniauth_provider', | ||
:as => 'disconnect_omniauth_provider' | ||
end | ||
|
||
# The priority is based upon order of creation: | ||
# first created -> highest priority. | ||
|
||
# Sample of regular route: | ||
# match 'products/:id' => 'catalog#view' | ||
# Keep in mind you can assign values other than :controller and :action | ||
|
||
# Sample of named route: | ||
# match 'products/:id/purchase' => 'catalog#purchase', :as => :purchase | ||
# This route can be invoked with purchase_url(:id => product.id) | ||
|
||
# Sample resource route (maps HTTP verbs to controller actions automatically): | ||
# resources :products | ||
|
||
# Sample resource route with options: | ||
# resources :products do | ||
# member do | ||
# get 'short' | ||
# post 'toggle' | ||
# end | ||
# | ||
# collection do | ||
# get 'sold' | ||
# end | ||
# end | ||
|
||
# Sample resource route with sub-resources: | ||
# resources :products do | ||
# resources :comments, :sales | ||
# resource :seller | ||
# end | ||
|
||
# Sample resource route with more complex sub-resources | ||
# resources :products do | ||
# resources :comments | ||
# resources :sales do | ||
# get 'recent', :on => :collection | ||
# end | ||
# end | ||
|
||
# Sample resource route within a namespace: | ||
# namespace :admin do | ||
# # Directs /admin/products/* to Admin::ProductsController | ||
# # (app/controllers/admin/products_controller.rb) | ||
# resources :products | ||
# end | ||
|
||
# You can have the root of your site routed with "root" | ||
# just remember to delete public/index.html. | ||
root :to => 'home#index' | ||
|
||
# See how all your routes lay out with "rake routes" | ||
|
||
# This is a legacy wild controller route that's not recommended for RESTful applications. | ||
# Note: This route will make all actions in every controller accessible via GET requests. | ||
# match ':controller(/:action(/:id))(.:format)' | ||
resources :stories do | ||
resources :comments | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateStories < ActiveRecord::Migration | ||
def change | ||
create_table :stories do |t| | ||
t.references :user, null: false | ||
t.string :title, null: false | ||
t.text :body, null: false | ||
|
||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class CreateComments < ActiveRecord::Migration | ||
def change | ||
create_table :comments do |t| | ||
t.references :user, null: false | ||
t.references :story, null: false | ||
t.text :body, null: false | ||
|
||
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
Empty file.
Empty file.
This file was deleted.
Oops, something went wrong.
Empty file.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Empty file.
Oops, something went wrong.