Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
works with 1.1.0.rc1, added index of wishlists
Browse files Browse the repository at this point in the history
  • Loading branch information
gudata committed Apr 21, 2012
1 parent a6f47f6 commit ebe8040
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -2,3 +2,4 @@ spec/dummy
spec/test_app
Gemfile.lock
*.swp
/nbproject/private/
6 changes: 6 additions & 0 deletions app/controllers/spree/wishlists_controller.rb
Expand Up @@ -10,6 +10,12 @@ def new
respond_with(@wishlist)
end

def index
@wishlists = current_user.wishlists

respond_with(@wishlist)
end

def edit
@wishlist = Spree::Wishlist.find_by_access_hash(params[:id])

Expand Down
2 changes: 2 additions & 0 deletions app/models/spree/wished_product.rb
@@ -1,4 +1,6 @@
class Spree::WishedProduct < ActiveRecord::Base
belongs_to :variant
belongs_to :wishlist

attr_accessible :wishlist_id, :variant_id
end
2 changes: 2 additions & 0 deletions app/models/spree/wishlist.rb
Expand Up @@ -3,6 +3,8 @@ class Spree::Wishlist < ActiveRecord::Base
has_many :wished_products
before_create :set_access_hash

attr_accessible :name, :is_default, :is_private

validates :name, :presence => true

def include?(variant_id)
Expand Down
6 changes: 6 additions & 0 deletions app/views/spree/wishlists/index.html.erb
@@ -0,0 +1,6 @@
<h1 class="row"><%= t(:wishlists) %></h1>
<%= content_tag :ul do %>
<% @wishlists.each do |wishlist| %>
<%= content_tag :li, link_to(wishlist.name, wishlist) %>
<% end %>
<% end %>
2 changes: 1 addition & 1 deletion config/routes.rb
@@ -1,4 +1,4 @@
Spree::Core::Engine.routes.append do
Spree::Core::Engine.routes.draw do
resources :wishlists
resources :wished_products, :only => [:create, :update, :destroy]
match '/wishlist' => "wishlists#show", :as => "default_wishlist"
Expand Down
4 changes: 2 additions & 2 deletions spree_wishlist.gemspec
Expand Up @@ -16,8 +16,8 @@ Gem::Specification.new do |s|
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
s.require_paths = ["lib"]

s.add_dependency 'spree_core', '>= 1.0.0'
s.add_dependency 'spree_auth', '>= 1.0.0'
s.add_dependency 'spree_core', '>= 1.1.0.rc1'
s.add_dependency 'spree_auth', '>= 1.1.0.rc1'

s.add_development_dependency 'factory_girl', '2.6.4'
s.add_development_dependency 'rspec-rails', '~> 2.9.0'
Expand Down

0 comments on commit ebe8040

Please sign in to comment.