Skip to content

Commit

Permalink
caching seems to working OK
Browse files Browse the repository at this point in the history
  • Loading branch information
benburkert committed Oct 6, 2008
1 parent 8894893 commit f8db267
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 2 deletions.
6 changes: 6 additions & 0 deletions app/controllers/books.rb
Expand Up @@ -48,6 +48,8 @@ def edit(id)
display @book
end

eager_cache(:update, [Dash, :index], :store => :action_store) { build_request(build_url(:dash)) }

def update(id, book)
debugger

Expand All @@ -70,6 +72,8 @@ def isbn_lookup(isbn)
redirect url(:book, @book)
end

eager_cache(:checkout, [Dash, :index], :store => :action_store) { build_request(build_url(:dash)) }

def checkout(id)
debugger
@book = Book.first(:slug => id) || (raise BookNotFound, id)
Expand All @@ -81,6 +85,8 @@ def checkout(id)
end
end

eager_cache(:checkin, [Dash, :index], :store => :action_store) { build_request(build_url(:dash)) }

def checkin(id)
@book = Book.first(:slug => id) || (raise BookNotFound, id)

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/reviews.rb
@@ -1,6 +1,8 @@
class Reviews < Application
before :ensure_authenticated

eager_cache(:create, [Dash, :index], :store => :action_store) { build_request(build_url(:dash)) }

def create(review)
debugger
book = Book.first(:slug => review[:book]) || raise(BookNotFound, review[:book])
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/users.rb
Expand Up @@ -8,6 +8,8 @@ def new
end
end

eager_cache(:create, [Dash, :index], :store => :action_store) { build_request(build_url(:dash)) }

def create(user)
@user = User.new(user)

Expand Down
4 changes: 2 additions & 2 deletions app/models/reservation.rb
Expand Up @@ -18,7 +18,7 @@ class Reservation
## Hooks
before :valid?, :set_timestamp_properties
after :create, :record_checkout
after :save, :record_checkin
after :update, :record_checkin

## Default Scope
default_scope(:default).update(:order => [:created_at.desc])
Expand Down Expand Up @@ -78,6 +78,6 @@ def record_checkout
end

def record_checkin
Activity::Checkin.create(:reservation => self, :created_at => self.returned_at, :user => self.user) if self.returned_at.nil?
Activity::Checkin.create(:reservation => self, :created_at => self.returned_at, :user => self.user)
end
end

0 comments on commit f8db267

Please sign in to comment.