Permalink
Browse files

Subscribe/unsubsribe almost working...

  • Loading branch information...
1 parent 11cc8b2 commit f79054a1a82f9b012e6ca1239dc2a900dff1f377 @stefanhorning committed Jan 28, 2012
Showing with 16 additions and 14 deletions.
  1. +1 −1 airtime/app/controllers/shows_controller.rb
  2. +10 −8 airtime/app/views/shows/show.html.erb
  3. +5 −5 airtime/config/database.yml
@@ -83,4 +83,4 @@ def destroy
format.json { head :ok }
end
end
-end
+end
@@ -11,17 +11,19 @@
<b>Description:</b> <%= @show.description %>
</p>
-<!-- current_user: <%= simple_format current_user.id.to_yaml %>
-all Subscribe: <%= simple_format Subscribe.all.to_yaml %>
-first Subscribe: <%= simple_format (Subscribe.find(1)).to_yaml %> -->
-Subscribe where user id is 'current_user.id' AND show_id is '@show.id': <%= simple_format (Subscribe.where("user_id = ? AND show_id = ?", current_user.id, @show.id)).to_yaml %>
-<!-- Subscribe.where("user_id = ? AND show_id = ?", current_user.id, @show.id).blank? -->
+<% if current_user %>
+
+<% @subscription = Subscribe.where("user_id = ? AND show_id = ?", current_user.id, @show.id) #find existing subscription %>
+
+<% if @subscription.blank? #if no subscription is found %>
+ <p>No subscription yet.</p>
-<% if true %>
- <% link_to 'Subscribe', shows_path %>
<% else %>
- <% link_to 'bla', shows_path %>
+ <p>You already subscribed to this show. Subscription ID: <%= @subscription.id.to_s %></p>
+ <%= link_to 'Unsubscribe', subscribe_path(@subscription.id), :confirm => "Are you sure?", :method => :delete %>
+<% end %>
+
<% end %>
<br />
@@ -14,8 +14,8 @@ development:
database: airtime_development
pool: 5
timeout: 5000
- username: jochen_knaack #postgresql user
- password: 1234
+ username: stefan #postgresql user
+ password: slsd4456
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
@@ -27,8 +27,8 @@ test: &test
database: airtime_test
pool: 5
timeout: 5000
- username: jochen_knaack #postgresql user
- password: 1234
+ username: stefan #postgresql user
+ #password: 1234
production:
#adapter: sqlite3
@@ -37,7 +37,7 @@ production:
database: db/airtime_production
pool: 5
timeout: 5000
- username: jochen_knaack #postgresql user
+ username: stefan #postgresql user
cucumber:
<<: *test

0 comments on commit f79054a

Please sign in to comment.