Forum: Ruby Ruby, Sinatra, DataMapper, and Heroku.what am I missing?

4c8d307323b0fe27757e27caa4518167?d=identicon&s=25 Brandon G. (brandon_g)
on 2011-05-23 10:41
Attachment: Ruby-Project.zip (200 KB)
All I'm trying to do is deploy an app I made using Heroku, because it
seemed simple enough when I read the instructions on various sites
explaining how to do this.

1.)Make a heroku account and install it
2.)Make a config.ru file in the root directory of the project containing

require 'movies' #movies is the name of my app
run Sinatra::Application

3.)Create the app on Heroku ($ heroku create)
4.) Use git and push the app to Heroku ($ git push heroku master)

I do all of this, and my app is being pushed to Heroku, but all I get is
an application error when I load the URL in a browser. So I run $ heroku
logs, and just get something telling me that it crashed, not giving me a
clue as to why. I was starting to think maybe it had to do with the
database? So I decided to try deploying a simple "hello world" app using
these same steps and I get the exact same error. What am I missing here?
I even tried using Bundler to make sure it gets all the required gems.

Link to github repository is https://github.com/bgerke/Ruby-Project for
anyone who is interested in helping me.
4c8d307323b0fe27757e27caa4518167?d=identicon&s=25 Brandon G. (brandon_g)
on 2011-05-23 11:04
Attachment: herokuLogs.txt (10 KB)
I attached the heroku logs, maybe someone here can make sense of them.
I'm already confused because they appear different from when I first
looked at them even though nothing has really changed.
E0d864d9677f3c1482a20152b7cac0e2?d=identicon&s=25 Robert Klemme (robert_k78)
on 2011-05-23 11:10
(Received via mailing list)
On Mon, May 23, 2011 at 11:05 AM, Brandon G. <b.a.gerke@gmail.com>
wrote:
> I attached the heroku logs, maybe someone here can make sense of them.
> I'm already confused because they appear different from when I first
> looked at them even though nothing has really changed.
>
> Attachments:
> http://www.ruby-forum.com/attachment/6219/herokuLogs.txt

You said "not giving me a clue as to why" but this is not true:

2011-05-23T07:36:38+00:00 heroku[web.1]: Starting process with
command: `thin -p 37458 -e production -R /home/heroku_rack/heroku.ru
start`
2011-05-23T07:36:39+00:00 app[web.1]:
<internal:lib/rubygems/custom_require>:29:in `require': no such file
to load -- movies (LoadError)
2011-05-23T07:36:39+00:00 app[web.1]:   from
<internal:lib/rubygems/custom_require>:29:in `require'

This tells you that a file named "movies" is attempted to be required
but Ruby interpreter cannot find it.  Either it is missing completely
or you do not have your load path configured properly.

Kind regards

robert
B31e7abd14f1ceb4c4957da08933c630?d=identicon&s=25 Josh Cheek (josh-cheek)
on 2011-05-23 11:13
(Received via mailing list)
On Mon, May 23, 2011 at 3:41 AM, Brandon G. <b.a.gerke@gmail.com> wrote:
> 3.)Create the app on Heroku ($ heroku create)
> Link to github repository is https://github.com/bgerke/Ruby-Project for
> anyone who is interested in helping me.
>
> Attachments:
> http://www.ruby-forum.com/attachment/6218/Ruby-Project.zip
>
>
> --
> Posted via http://www.ruby-forum.com/.
>
>


Your logs say: "2011-05-23T08:31:50+00:00 app[web.1]:
<internal:lib/rubygems/custom_require>:29:in `require': no such file
to load -- movies (LoadError)"

On Ruby < 1.9.2, the current directory is part of the path, so if you
run the app from the app's directory, it will happen to find the
movies file. But this behaviour is unreliable, so in 1.9.2, they
removed the current directory from the path. This means you need to
either be explicit about the location of the file, or alter the path
to include your app's directory.
The easiest solution os to change `require "movies"` to `require
File.dirname(__FILE__)+"/movies"`

Additionally, looking at your source code, you have another issue that
will come up. You are not actually using Bundler. You need to put
`require 'bundler/setup'` before you require any of your gems.

I also see that Datamapper is not in your Gemfile. You don't notice
this problem, because your app isn't loading bundler. As soon as you
fix that, it will become apparent.
4c8d307323b0fe27757e27caa4518167?d=identicon&s=25 Brandon G. (brandon_g)
on 2011-05-23 11:58
Attachment: herokuLogs2.txt (10 KB)
Thank you both very much, so far you both have been helpful.

Now I added DataMapper to the Gemfile, and it installed it. Added
`require 'bundler/setup'` to movies.db, and changed `require "movies"`
to `require
File.dirname(__FILE__)+"/movies"` in the config file. Everything pushed
to Heroku just fine after these changes, but I still get errors that I'm
not sure how to solve.

/app/.bundle/gems/ruby/1.9.1/gems/dm-core-1.1.0/lib/dm-core/adapters.rb:163:in
`require': no such file to load -- dm-sqlite-adapter (LoadError)

I also attached a new heroku log in case there are other errors I am not
seeing.


Thanks in advance for your help, greatly appreciate it.
4c8d307323b0fe27757e27caa4518167?d=identicon&s=25 Brandon G. (brandon_g)
on 2011-05-23 12:55
I decided to add gem 'dm-sqlite-adapter' to the gemfile and for some
reason this fixed my last problem. It's up and working now. ^_^
4c8d307323b0fe27757e27caa4518167?d=identicon&s=25 Brandon G. (brandon_g)
on 2011-05-23 13:12
Attachment: herokuLogs3.txt (10 KB)
Okay it's not really working I got excited and didn't bother testing it
after I saw something appear on each page. I get an internal server
error when attempting to submit anything from the form.

DataObjects::ConnectionError - attempt to write a readonly database:

How would I change it to a read/write?

PS: Tried to add this to the last post, but took just a hair too long.
Didn't realize you had to make edits within 15 minutes.
3553e3cd24ab66b1acb49f5ad1238043?d=identicon&s=25 Roger Braun (Guest)
on 2011-05-23 15:03
(Received via mailing list)
2011/5/23 Brandon G. <b.a.gerke@gmail.com>:
> Okay it's not really working I got excited and didn't bother testing it
> after I saw something appear on each page. I get an internal server
> error when attempting to submit anything from the form.
>
> DataObjects::ConnectionError - attempt to write a readonly database:
>
> How would I change it to a read/write?

You can't use SQLite on Heroku, you have to use their PostgreSQL
database. Instead of

  Datamapper.setup(:default, "sqlite:some.db")

use

  Datamapper.setup(:default, ENV["DATABASE_URL"] || "sqlite:some.db")

This will work both locally and on Heroku. You will also need to add
dm-postgres-adapter to your Gemfile.
Please log in before posting. Registration is free and takes only a minute.
Existing account

NEW: Do you have a Google/GoogleMail, Yahoo or Facebook account? No registration required!
Log in with Google account | Log in with Yahoo account | Log in with Facebook account
No account? Register here.