ivanoats (2) [Avatar] Offline
#1
I've run into a lot of problems downloading the sample code and getting it running. Is it possible for you to create a version that works "out of the box" so that everyone can see the end result of what we're building in the book?

First issue:
→ bundle
The path `/Users/ivan/dev/rails3inaction/forem` does not exist.

seem to have resolved it by cloning forem from the directory above

Next issue:
Could not find Repository radar/rack-test
changed the Gemfile to comment out link to missing git repo and use the standard rack-test from rubygems

Next issue:
Could not find gem 'ticketee-forem (>= 0) ruby' in source at ../forem.
Source does not contain any versions of 'ticketee-forem (>= 0) ruby'

gave up after there...
ryanbigg (423) [Avatar] Offline
#2
Re: How to build final app?
Hi,

I've fixed this in the example's Gemfile now. It should be git://github.com/rails3book/forem, rather than git://github.com/radar/forem. This is because the first one is the ticketee-forem that we build in the book, where the second one is a... well, it's kind of a mutation/evolution from the original idea smilie

Does that help you now?
robmi (3) [Avatar] Offline
#3
I was able to build the app with these instructions and Gemfile.
Hi,

First of all, I would like to thank Ryan for an excellent book - I learned a lot!

Here is the instructions which I used to get the code on GitHub, excluding the forem feature, working on ubuntu 11.10.

Enviroment Setup
=================
Install node.js:
https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager
(I started out the therubyracer but then had this problem here: https://github.com/cucumber/cucumber/issues/134)

Install on a fresh gemset
=========================

Install bundler.
>gem install bundler

Install the ticketee app.
-------------------------
>git clone https://github.com/rails3book/ticketee.git

I created a Gemfile with all the gems versioned in order that these instructions would be future proof.
I will post the Gemfile separately in this thread.

Replace the Gemfile in the application with my new Gemfile and remove the Gemfile.lock file.

Install the gemfiles.
>bundle install

Oops this happens:
Could not find gem 'sprockets (= 2.0.0.beta.10) ruby' in any of the gem sources listed in your Gemfile.

It seems gem versions eventually go out of circulation, but you can usually down load them manually.

Install the sprockets gem manually like this.

Download the zip file, found here ( https://github.com/sstephenson/sprockets/zipball/v2.0.0.beta.10 ) into a temporary directory outside the ticketee app.
Unzip the directory and cd into it.

>cd sstephenson-sprockets-64fe8b0
Build the gem.
>gem build sprockets.gemspec

Install the gem
>gem install sprockets.gem

Go back to the ticketee directory and install the gems.
>bundle install

Now chop out the forem stuff.
-----------------------------

Remove the schema file
>rm db/schema.rb

Remove the forem migrations.
cd db/migrate
> rm *forem*

Also
> rm 20110609020054_add_project_id_index_to_tickets.rb

Otherwise you will get an error that says: 'Index name 'index_tickets_on_project_id' on table 'tickets' already exists' when you run migrations, later.

Prevent forem from mounting in routes.rb by commenting out like this:
#mount Forem::Engine, :at => "/forem"

Prevent forem from initializing by commenting out config/initializers/forem.rb like this:
#Forem::Engine.user_class = User

Run the database migrations.
>bundle exec rake db:migrate

Now you should be ready to run your tests.

>bundle exec rake cucumber:ok

This is the result.

66 scenarios (28 failed, 2 skipped, 36 passed)
752 steps (28 failed, 141 skipped, 583 passed)

Many errors were because of this:

Cannot modify SafeBuffer in place (ActionView::Template::Error)
/home/rob/.rvm/gems/ruby-1.9.2-p290@ticketee-mypost/gems/activesupport-3.1.0.rc2/lib/active_support/core_ext/string/output_safety.rb:129:in `gsub!'
/home/rob/.rvm/gems/ruby-1.9.2-p290@ticketee-mypost/gems/actionpack-3.1.0.rc2/lib/action_view/helpers/text_helper.rb:261:in `simple_format'

I fixed this with the patch as follows, however I do not know how "official" the fix is. You can use it at your own risk !

Edit $GEM_HOME/actionpack-3.1.0.rc2/lib/action_view/helpers/text_helper.rb.

Replace the modification in place !methods from lines 261 to 263 in the simple_format method with the fix below:

#Fix start SafeBuffer raises an exception for modifications in place
text = text.gsub(/
?/, "
") #
and ->

text = text.gsub(/

+/, "



#{start_tag}"smilie # 2+ newline -> paragraph
text = text.gsub(/([^
]
)(?=[^
])/, '1
') # 1 newline -> br
#Fix end

Rerun the failing cucumber tests again.
>bundle exec rake cucumber:rerun

Much better now. I get this result.

Failing Scenarios:
cucumber features/gmail.feature:20 # Scenario: Receiving a real-world email
cucumber features/signing_in.feature:6 # Scenario: Signing in via confirmation
cucumber features/ticket_notifications.feature:20 # Scenario: Ticket owner is automatically subscribed to a ticket

66 scenarios (3 failed, 1 skipped, 62 passed)
752 steps (3 failed, 45 skipped, 704 passed)

Errors:
deadlock; recursive locking (ThreadError)
Could not find table 'delayed_jobs' (ActiveRecord::StatementInvalid)

I was able to get the features/gmail.feature to pass by patching the gmail gem according to the fix mentioned here:
https://github.com/nu7hatch/gmail/pull/28/files

Edit $GEM_HOME/gems/gmail-0.4.0/lib/gmail/client/base.rb as follows:

def mailbox(name, &block)
@mailbox_mutex = Mutex.new # Insert this code here, between lines 153 and 154
@mailbox_mutex.synchronize do

Rerun cucumber tests again.
>bundle exec rake cucumber:rerun

Failing Scenarios:
cucumber -p rerun features/signing_in.feature:6 # Scenario: Signing in via confirmation
cucumber -p rerun features/ticket_notifications.feature:20 # Scenario: Ticket owner is automatically subscribed to a ticket

3 scenarios (2 failed, 1 passed)
41 steps (2 failed, 22 skipped, 17 passed)

Errors:
Could not find table 'delayed_jobs' (ActiveRecord::StatementInvalid)

Fix the above error by:creating the database tables for delayed_jobs.

>bundle exec rails g delayed_job:active_record
>bundle exec rake db:migrate

Run cucumber again.

>bundle exec rake cucumber:ok

66 scenarios (66 passed)
752 steps (752 passed)

Done !
robmi (3) [Avatar] Offline
#4
Here is my Gemfile
source 'http://rubygems.org'

gem 'rails', '3.1.0.rc2'
gem 'multipart-post', '1.1.2'

gem 'rack', '1.3.6'
gem 'rack-cache', '1.0.2'
gem 'rack-mount', '0.8.1'

gem 'arel', '2.1.1'

gem 'diff-lcs', '1.1.2'

gem 'configuration', '1.2.0'

gem 'sqlite3', '1.3.3'

gem 'sass', '3.1.2'
gem 'coffee-script', '2.2.0'
gem 'coffee-script-source', '1.1.1'
gem 'execjs', '1.1.1'
gem 'json', '1.5.1'
gem 'multi_json', '1.0.3'

gem 'sprockets', '2.0.0.beta.10'

gem 'dynamic_form', '1.1.4'


gem 'devise', '1.4.2'

gem 'cancan', '1.6.5'

gem 'paperclip', '2.3.10'
gem 'cocaine', '0.1.0'

gem 'searcher', '0.0.6'
gem 'kaminari', '0.12.4'

gem 'jquery-rails', '1.0.9'
gem "oa-oauth", '0.2.6', :require => "omniauth/oauth"
gem 'oauth', '0.4.4'

gem "delayed_job", '3.0.0.pre'
gem 'delayed_job_active_record', '0.2.2'

#gem "forem", :git => 'git://github.com/rails3book/forem'
#gem "ticketee-forem", :require => "forem", :path => "../forem"


gem 'sinatra', '1.2.6'

gem 'hike', '1.0.0'

gem 'polyglot', '0.3.1'

gem 'tzinfo', '0.3.27'

gem 'term-ansicolor', '1.0.5'

gem 'tilt', '1.3.2'

gem 'treetop', '1.4.9'

group :test, :development do
gem 'gmail', '0.4.0'
gem 'rspec-rails', '2.6.1'
gem 'ruby-debug-base19', '0.11.25'
gem 'ruby-debug-ide', '0.4.9'
end

group :test do
# gem 'rack-test', :git => "git://github.com/radar/rack-test"

gem 'cucumber', '0.10.6'
gem 'cucumber-rails', '0.5.2'
gem 'gherkin', '2.4.0'

gem 'capybara', '1.1.2'
gem 'database_cleaner', '0.6.7'
gem 'factory_girl', '1.3.3'
gem 'email_spec', '1.1.1'
gem 'launchy', '0.4.0'
gem 'selenium-webdriver', '2.13.0'
end

group :production do
gem 'pg', '0.11.0'
end
sasham (3) [Avatar] Offline
#5
Re: How to build final app?
Ryan, why not bundle lock the gems and stop referencing the git from the Gemfile? I mean, maybe there are the reasons - but the fact is - the code does not work out of the box. You can't do bundle install, migrate and run. This is frustrating because I wanted to check out the app because for a few features, I wanted the code first - and maybe then look into the book for details if necessary.
ryanbigg (423) [Avatar] Offline
#6
Re: How to build final app?
Could you please explain how it's not working for you?
sasham (3) [Avatar] Offline
#7
Re: How to build final app?
robmi has got it. I used his guides to get the app started.
Brett Sanders (8) [Avatar] Offline
#8
Re: I was able to build the app with these instructions and Gemfile.
Hey Robmi, Thanks for taking the time to post these steps.

I have a few questions :

1. Why do we need Node.js for this app? I didn't get through the full book, but wanted to see the finished version. It's unclear to me why we need Node.js

2. After modifying the ActionPack texthelper.rb file, I then ran the tests and keep getting this Firefox popup error. It asks for some info. Did you run into this problem? If so, if you know how to get around it, it would be great.

Here's a screenshot
http://grab.by/cUU2

The error says:
unable to obtain stable firefox connection in 60 seconds (127.0.0.1:7055) (Selenium::WebDriver::Error::WebDriverError)

The error occurs twice, leading to 5 errors total.

Someone else got this error here:
http://www.manning-sandbox.com/message.jspa?messageID=117618

I ran "bundle update" but didn't help.
My version of Firefox is 11
gem 'capybara', '1.1.2'
gem 'selenium-webdriver', '2.13.0'

Thanks again for your great post.

Message was edited by:
Brett Sanders
ryanbigg (423) [Avatar] Offline
#9
Re: I was able to build the app with these instructions and Gemfile.
1. You don't need Node.js for this application. You need the libv8 package installed on your system and one of the easiest ways to get this is to install Node.js. You could probably just install the libv8 package without Node.js.

2. What caused you to need to modify text_helper.rb? You shouldn't have to do this.

The Firefox message here is purely a diagnostic error message and looks to be from (possibly) an older version of Firefox or selenium-webdriver. I'd recommend upgrading both of those.
Brett Sanders (8) [Avatar] Offline
#10
Re: I was able to build the app with these instructions and Gemfile.
Hey Ryan,

Thanks for the clarification on the libv8.

The only reason I modified the text_helper.rb was because I was following Robmi's instructions in this thread. I didn't understand the reasons for it.

What I'd like is to be able to get the source code from the download here ( http://www.manning.com/katz/ ) working on my local machine.

I've run into a lot of errors trying to get this to work.

Would you be able to post instructions on how you would do it, so then others would be able to try your method and see where it fails?

It would be great to have the final project actually working from the source download. Thanks!
ryanbigg (423) [Avatar] Offline
#11
Re: I was able to build the app with these instructions and Gemfile.
Please try the source from http://github.com/rails3book/ticketee rather than the one Manning hosts on their website. The reason for this is that I can easily update the one on GitHub, where I cannot do the same for the one on Manning's site. I wish that they would just link to the GitHub version.
Brett Sanders (8) [Avatar] Offline
#12
Re: I was able to build the app with these instructions and Gemfile.
Thanks Ryan,

Here's what I'm getting

> git clone http://github.com/rails3book/ticketee

Then
> bundle install

Then this error comes up:
Git error: command `git clone 'git://github.com/radar/rack-test' "/Users/brettsanders/.rvm/gems/ruby-1.9.2-p290/cache/bundler/git/rack-test-8ce034d275474b0b137179c1bd5be3e5ee2e2464" --bare --no-hardlinks` in directory /Users/brettsanders/Desktop/ticketee has failed.
ryanbigg (423) [Avatar] Offline
#13
Re: I was able to build the app with these instructions and Gemfile.
Alright, please try again. The project hasn't been maintained terribly well, but at least I can update it as you come across problems.

Currently working on an update for the book (and therefore the application's example code) which should make everything better.
Brett Sanders (8) [Avatar] Offline
#14
Re: I was able to build the app with these instructions and Gemfile.
Thanks for updating Ryan

here's what I did

> git clone http://github.com/rails3book/ticketee

cd into directory

> bundle install
no problems this time

> rake db:migrate
no problems

> rails s

when i visit localhost, app appears fine
i can log in with twitter
i can sign up (no real email sent for confirmation)
i CAN'T log in with github

i get this error with github login
SQLite3::ConstraintException in Users::OmniauthCallbacksController#github
users.email may not be NULL
here's screenshot of github error
http://grab.by/cVre

here are questions i have:
1. how can i configure the app to send email so i can sign in?
2. how fix github login?
3. should i be able to create tickets as user? there are no projects when i login.
4. how can i create or login as admin so i can create projects? i'd like to see full app in action

thanks for your help ryan, i appreciate it. i'd really like to have the complete app working before i go through the book again. i got stuck around chapters 8 and 9 the first couple times i went through book and realized it would help to see final app working. also, i'd like to try adding features to final app and want to have finished version to mess around with.