Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/zacstewart/Vimbits
Browse files Browse the repository at this point in the history
  • Loading branch information
kkuchta committed Feb 29, 2012
2 parents 355173b + 82a27b7 commit 2dd2f3f
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 9 deletions.
7 changes: 4 additions & 3 deletions app/controllers/bits_controller.rb
Expand Up @@ -26,10 +26,11 @@ def index
@bits = @bits.tagged_with params[:tag]
# :tags is a json tag string array
# (only uses first tag for now)
# Should this be an OR or an AND operation?
elsif params[:tags]
tagsArray = ActiveSupport::JSON.decode(params[:tags])
if tagsArray.length > 0
@bits = @bits.tagged_with tagsArray.first
@tagsArray = ActiveSupport::JSON.decode(params[:tags])
if @tagsArray.any?
@bits = @bits.tagged_with @tagsArray.first
end
end

Expand Down
14 changes: 12 additions & 2 deletions app/views/bits/index.html.haml
@@ -1,9 +1,19 @@
%p#notice= notice

- cache do
%h1= @title
%h1
= @title
- if params[:tag].present?
tagged #{params[:tag]}
- elsif @tagsArray.present?
tagged #{@tagsArray.to_sentence}
- content_for(:title) do
= params[:sort].capitalize
- if params[:sort].present?
= params[:sort].capitalize
- elsif params[:tag].present?
= params[:tag].capitalize
- elsif @tagsArray
= @tagsArray.to_sentence.capitalize

.row
%form.tag-search{ method:'get', action:('/bits') }
Expand Down
8 changes: 4 additions & 4 deletions db/schema.rb
Expand Up @@ -15,11 +15,11 @@

create_table "bits", :force => true do |t|
t.string "title"
t.text "code", :limit => 5000
t.text "description", :limit => 5000
t.text "code"
t.text "description"
t.integer "user_id"
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
t.datetime "created_at", :null => false
t.datetime "updated_at", :null => false
end

create_table "comments", :force => true do |t|
Expand Down

0 comments on commit 2dd2f3f

Please sign in to comment.