Skip to content
Browse files

Merge branch 'master' of https://github.com/zacstewart/Vimbits

  • Loading branch information...
2 parents 355173b + 82a27b7 commit 2dd2f3f611037766a7bba6a60877efb5673f4833 @kkuchta committed Feb 28, 2012
Showing with 20 additions and 9 deletions.
  1. +4 −3 app/controllers/bits_controller.rb
  2. +12 −2 app/views/bits/index.html.haml
  3. +4 −4 db/schema.rb
View
7 app/controllers/bits_controller.rb
@@ -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
View
14 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') }
View
8 db/schema.rb
@@ -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|

0 comments on commit 2dd2f3f

Please sign in to comment.
Something went wrong with that request. Please try again.