Skip to content

Commit

Permalink
tags page
Browse files Browse the repository at this point in the history
  • Loading branch information
miros committed Sep 30, 2010
1 parent c5289cf commit 0e272fc
Show file tree
Hide file tree
Showing 10 changed files with 184 additions and 83 deletions.
13 changes: 10 additions & 3 deletions .idea/answers.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

210 changes: 137 additions & 73 deletions .idea/workspace.xml

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions Gemfile
Expand Up @@ -7,6 +7,7 @@ gem 'flutie'
gem 'nifty-generators'
gem 'rutils'
gem 'maruku'
gem "will_paginate", "~> 3.0.pre2"

# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
Expand Down
12 changes: 7 additions & 5 deletions Gemfile.lock
Expand Up @@ -32,15 +32,15 @@ GEM
activesupport (~> 3.0.0)
bcrypt-ruby (2.1.2)
builder (2.1.2)
devise (1.1.2)
devise (1.1.3)
bcrypt-ruby (~> 2.1.2)
warden (~> 0.10.7)
diff-lcs (1.1.2)
erubis (2.6.6)
abstract (>= 1.0.0)
flutie (1.0.4)
gilenson (1.1.1)
haml (3.0.18)
haml (3.0.21)
i18n (0.4.1)
mail (2.2.6.1)
activesupport (>= 2.3.6)
Expand All @@ -49,13 +49,13 @@ GEM
maruku (0.6.0)
syntax (>= 1.0.0)
mime-types (1.16)
nifty-generators (0.4.0)
nifty-generators (0.4.1)
pg (0.9.0)
polyglot (0.3.1)
rack (1.2.1)
rack-mount (0.6.13)
rack (>= 1.0.0)
rack-test (0.5.4)
rack-test (0.5.6)
rack (>= 1.0)
rails (3.0.0)
actionmailer (= 3.0.0)
Expand Down Expand Up @@ -86,12 +86,13 @@ GEM
rutils (1.1.1)
gilenson
syntax (1.0.0)
thor (0.14.0)
thor (0.14.2)
treetop (1.4.8)
polyglot (>= 0.3.1)
tzinfo (0.3.23)
warden (0.10.7)
rack (>= 1.0.0)
will_paginate (3.0.pre2)

PLATFORMS
ruby
Expand All @@ -107,3 +108,4 @@ DEPENDENCIES
rspec (>= 2.0.0.beta.22)
rspec-rails (>= 2.0.0.beta.22)
rutils
will_paginate (~> 3.0.pre2)
2 changes: 1 addition & 1 deletion app/controllers/home_controller.rb
Expand Up @@ -2,7 +2,7 @@ class HomeController < ApplicationController

def index

@questions = Question.limit(20)
@questions = Question.paginate :page => params[:page]

end

Expand Down
10 changes: 10 additions & 0 deletions app/controllers/tags_controller.rb
@@ -0,0 +1,10 @@
class TagsController < ApplicationController

def show

@tag = Tag.find(params[:id])
@questions = @tag.questions.paginate :page => params[:page]

end

end
5 changes: 5 additions & 0 deletions app/models/question.rb
@@ -1,5 +1,10 @@
class Question < Post

cattr_reader :per_page
@@per_page = 3

default_scope order('created_at DESC')

include Sluggable

use_as_slug :title
Expand Down
7 changes: 7 additions & 0 deletions app/views/home/index.html.haml
Expand Up @@ -2,5 +2,12 @@
#questions_list
= render :partial => "question", :collection => @questions

%pages
= will_paginate @questions

%br
%br

%p
=link_to 'Задать вопрос', new_question_path

2 changes: 1 addition & 1 deletion app/views/tags/_tag.html.haml
@@ -1 +1 @@
%a.post_tag= tag.name
= link_to tag.name, tag, :class => :post_tag
5 changes: 5 additions & 0 deletions app/views/tags/show.html.haml
@@ -0,0 +1,5 @@
#questions_list
= render :partial => "/home/question", :collection => @questions

%pages
= will_paginate @questions

0 comments on commit 0e272fc

Please sign in to comment.