Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
/.bundle
/db/*.sqlite3
/log/*.log
/tmp
/bin
.bundle
db/*.sqlite3
log
*.log
tmp
bin
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--colour --profile --order random
36 changes: 8 additions & 28 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,45 +1,25 @@
source 'https://rubygems.org'

gem 'rails', '3.2.7'

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'

gem 'sqlite3'

gem 'jquery-rails'
gem "paperclip"
gem 'sorcery'
gem 'haml-rails'

# Gems used only for assets and not required
# in production environments by default.
group :assets do
gem 'sass-rails', '~> 3.2.3'
gem 'coffee-rails', '~> 3.2.1'

# See https://github.com/sstephenson/execjs#readme for more supported runtimes
# gem 'therubyracer', :platforms => :ruby

gem 'uglifier', '>= 1.0.3'
gem "twitter-bootstrap-rails", "~> 2.1.3"
end

gem 'jquery-rails'

# To use ActiveModel has_secure_password
# gem 'bcrypt-ruby', '~> 3.0.0'

# To use Jbuilder templates for JSON
# gem 'jbuilder'

# Use unicorn as the app server
# gem 'unicorn'

# Deploy with Capistrano
# gem 'capistrano'

# To use debugger
# gem 'debugger'
gem "paperclip"
gem 'sorcery'
gem 'haml-rails'
group :test do
gem 'rspec-rails'
gem 'shoulda-matchers'
end

group :development do
gem 'hpricot'
Expand Down
54 changes: 36 additions & 18 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ GEM
multi_json (~> 1.0)
arel (3.0.2)
bcrypt-ruby (3.0.1)
builder (3.0.0)
cocaine (0.2.1)
builder (3.0.3)
cocaine (0.3.0)
coffee-rails (3.2.2)
coffee-script (>= 2.2.0)
railties (~> 3.2.0)
Expand All @@ -40,26 +40,27 @@ GEM
execjs
coffee-script-source (1.3.3)
commonjs (0.2.6)
diff-lcs (1.1.3)
erubis (2.7.0)
execjs (1.4.0)
multi_json (~> 1.0)
faraday (0.8.1)
faraday (0.8.4)
multipart-post (~> 1.1)
haml (3.1.7)
haml-rails (0.3.4)
actionpack (~> 3.0)
activesupport (~> 3.0)
haml (~> 3.0)
railties (~> 3.0)
haml-rails (0.3.5)
actionpack (>= 3.1, < 4.1)
activesupport (>= 3.1, < 4.1)
haml (~> 3.1)
railties (>= 3.1, < 4.1)
hike (1.2.1)
hpricot (0.8.6)
httpauth (0.1)
i18n (0.6.0)
i18n (0.6.1)
journey (1.0.4)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
jquery-rails (2.1.2)
railties (>= 3.1.0, < 5.0)
thor (~> 0.14)
json (1.7.4)
json (1.7.5)
less (2.2.2)
commonjs (~> 0.2.6)
less-rails (2.2.3)
Expand All @@ -73,12 +74,12 @@ GEM
mime-types (1.19)
multi_json (1.3.6)
multipart-post (1.1.5)
oauth (0.4.6)
oauth (0.4.7)
oauth2 (0.6.1)
faraday (~> 0.7)
httpauth (~> 0.1)
multi_json (~> 1.3)
paperclip (3.1.4)
paperclip (3.2.0)
activemodel (>= 3.0.0)
activerecord (>= 3.0.0)
activesupport (>= 3.0.0)
Expand Down Expand Up @@ -110,14 +111,29 @@ GEM
rake (0.9.2.2)
rdoc (3.12)
json (~> 1.4)
rspec (2.11.0)
rspec-core (~> 2.11.0)
rspec-expectations (~> 2.11.0)
rspec-mocks (~> 2.11.0)
rspec-core (2.11.1)
rspec-expectations (2.11.3)
diff-lcs (~> 1.1.3)
rspec-mocks (2.11.2)
rspec-rails (2.11.0)
actionpack (>= 3.0)
activesupport (>= 3.0)
railties (>= 3.0)
rspec (~> 2.11.0)
ruby_parser (2.3.1)
sexp_processor (~> 3.0)
sass (3.1.20)
sass (3.2.1)
sass-rails (3.2.5)
railties (~> 3.2.0)
sass (>= 3.1.10)
tilt (~> 1.3)
sexp_processor (3.2.0)
shoulda-matchers (1.3.0)
activesupport (>= 3.0.0)
sorcery (0.7.13)
bcrypt-ruby (~> 3.0.0)
oauth (~> 0.4.4)
Expand All @@ -129,7 +145,7 @@ GEM
sqlite3 (1.3.6)
therubyracer (0.10.2)
libv8 (~> 3.3.10)
thor (0.15.4)
thor (0.16.0)
tilt (1.3.3)
treetop (1.4.10)
polyglot
Expand All @@ -140,9 +156,9 @@ GEM
railties (>= 3.1)
therubyracer (~> 0.10.2)
tzinfo (0.3.33)
uglifier (1.2.7)
uglifier (1.3.0)
execjs (>= 0.3.0)
multi_json (~> 1.3)
multi_json (~> 1.0, >= 1.0.2)

PLATFORMS
ruby
Expand All @@ -154,8 +170,10 @@ DEPENDENCIES
jquery-rails
paperclip
rails (= 3.2.7)
rspec-rails
ruby_parser
sass-rails (~> 3.2.3)
shoulda-matchers
sorcery
sqlite3
twitter-bootstrap-rails (~> 2.1.3)
Expand Down
3 changes: 0 additions & 3 deletions app/controllers/tags_controller.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
class TagsController < ApplicationController
has_many :taggings, :dependant => :destroy
def index
@articles = Article.all
end

def show
@tag = Tag.find(params[:id])
end


end
12 changes: 4 additions & 8 deletions app/models/article.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,21 @@ class Article < ActiveRecord::Base
has_many :tags, :through => :taggings
has_attached_file :image


def tag_list
self.tags.collect do |tag|
tag.name
end.join(", ")
end




def tag_list=(tags_string)
self.taggings.destroy_all

tag_names = tags_string.split(",").collect{|s| s.strip.downcase}.uniq

tag_names.each do |tag_name|
tag = Tag.find_or_create_by_name(tag_name)
tagging = self.taggings.new
tagging.tag_id = tag.id
tag = Tag.find_or_create_by_name(tag_name)
tagging = self.taggings.new
tagging.tag_id = tag.id
end
end
end
end
1 change: 0 additions & 1 deletion app/models/author.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
class Author < ActiveRecord::Base
authenticates_with_sorcery!
#attr_accessible :crypted_password, :email, :salt, :username
attr_accessible :username, :email, :password, :password_confirmation

validates_confirmation_of :password, :message => "should match confirmation", :if => :password
Expand Down
1 change: 0 additions & 1 deletion app/models/comment.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
class Comment < ActiveRecord::Base

attr_accessible :author_name, :body

belongs_to :article
Expand Down
2 changes: 1 addition & 1 deletion app/models/tag.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,6 @@ class Tag < ActiveRecord::Base
has_many :articles, :through => :taggings

def to_s
name
name
end
end
Empty file removed log/.gitkeep
Empty file.
9 changes: 9 additions & 0 deletions spec/models/article_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
require 'spec_helper'

describe Article do
describe "Associations" do
it { should have_many(:comments) }
it { should have_many(:taggings) }
it { should have_many(:tags) }
end
end
7 changes: 7 additions & 0 deletions spec/models/comment_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
require 'spec_helper'

describe Comment do
describe "Associations" do
it { should belong_to(:article) }
end
end
8 changes: 8 additions & 0 deletions spec/models/tag_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'

describe Tag do
describe "Associations" do
it { should have_many(:taggings) }
it { should have_many(:articles) }
end
end
8 changes: 8 additions & 0 deletions spec/models/tagging_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'spec_helper'

describe Tagging do
describe "Associations" do
it { should belong_to(:article) }
it { should belong_to(:tag) }
end
end
38 changes: 38 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# This file is copied to spec/ when you run 'rails generate rspec:install'
ENV["RAILS_ENV"] ||= 'test'
require File.expand_path("../../config/environment", __FILE__)
require 'rspec/rails'
require 'rspec/autorun'

# Requires supporting ruby files with custom matchers and macros, etc,
# in spec/support/ and its subdirectories.
Dir[Rails.root.join("spec/support/**/*.rb")].each {|f| require f}

RSpec.configure do |config|
# ## Mock Framework
#
# If you prefer to use mocha, flexmock or RR, uncomment the appropriate line:
#
# config.mock_with :mocha
# config.mock_with :flexmock
# config.mock_with :rr

# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
config.fixture_path = "#{::Rails.root}/spec/fixtures"

# If you're not using ActiveRecord, or you'd prefer not to run each of your
# examples within a transaction, remove the following line or assign false
# instead of true.
config.use_transactional_fixtures = true

# If true, the base class of anonymous controllers will be inferred
# automatically. This will be the default behavior in future versions of
# rspec-rails.
config.infer_base_class_for_anonymous_controllers = false

# Run specs in random order to surface order dependencies. If you find an
# order dependency and want to debug it, you can fix the order by providing
# the seed, which is printed after each run.
# --seed 1234
config.order = "random"
end