The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

rails3dev (20) [Avatar] Offline
#1
In 2012 published edition

Has anybody gotten this watcher to work. Interrogating the join table reveals that event after switching between multiple users, that each one that creates a comment does not get added to the watch list.

Checking against GitHub branch Chapter 12 suggests that my code is identical.

Was this tested other than in Cucumber? Any help appreciated.

Really enjoying the variety in this book. Just wish I knew more to be able to 'self-help'
rails3dev (20) [Avatar] Offline
#2
Re: Chapter 12, Section 12.2.2 - Automatically adding a user to a watchlist
Ah, it seemed a restart of the rails server was required to get this working.

Please note that while I am following the book because of the early issues with Cucumber I abandoned most of the cukes stuff as I had wanted to learn this to support the new way.

Hoping that Ryan will at some point revise the book with the 'cuke without training wheels' method.

Cheers
ryanbigg (423) [Avatar] Offline
#3
Re: Chapter 12, Section 12.2.2 - Automatically adding a user to a watchlist
iirc, that was set up using an observer which would be set up in config/application.rb. So yes, you will need to restart your server when this file is changed.

Is that not mentioned on that page?
rails3dev (20) [Avatar] Offline
#4
Re: Chapter 12, Section 12.2.2 - Automatically adding a user to a watchlist
Hi Ryan

Thanks for the response. I have read, and re-read the sections 12.1.1 (Automatically watching a ticket) through 12.1.3 (Defining the watchers association) and can find no reference to restarting the server following changing the config/application.rb file.

Please note that I am not running the cucumber stuff as I wanted to learn to use Declarative Scenarios vs Imperative Scenarios (which as far as I can tell are what we primarily use in R3IA in web_steps.rb - Please correct me if I have misunderstood this, there is so many new concepts to learn).

As a result of not using Cucumber, I am following the RSpec work and doing all my testing with the Browser. Maybe this is why I have picked up a few more errors (mainly mine! smilie ).

As an aside, I found that each time Alice added a comment she was added to the watchers list again. I am not sure if this is meant to happen.

To get around this I changed the code in comments.rb file
from:
def creator_watches_ticket
ticket.watchers << user
end

to:
def creator_watches_ticket
unless self.ticket.watchers.exists?(user)
ticket.watchers << user
end
end

Would be interested in your views as to whether this needed to be done, and/or was in the correct place?

Regards