Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panda level submission #12

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open

Conversation

jperezish
Copy link

Here's my Panda level. App deployed to Heroku as well.

@jwo
Copy link
Member

jwo commented Jan 15, 2014

Nicely done! Everything works, looks great. 🎉

@jperezish
Copy link
Author

@jwo I updated this with tiger. I updated the Heroku site as well.

@@ -16,3 +13,9 @@
@the_number = rand(number_as_string)
erb :number
end

get '/' do
my_picks = YAML.load(File.read("./my_picks.yml"))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NICE!!!

Each time the page loads, it will need to pick up this file and interpret the yml file.

I'm going to push you a pick on this: Can you think of a way to have these picks be a Ruby class that dont' change?

@jwo
Copy link
Member

jwo commented Jan 30, 2014

Hey @jperezish ---

Check out these lines: https://github.com/jperezish/Episode8/blob/master/db/setup.rb#L10-L11

ActiveRecord::Base.connection.drop_database (connection_details.fetch('database')) rescue nil
ActiveRecord::Base.connection.create_database(connection_details.fetch('database')) rescue nil

I bet you're having trouble dropping and creating the DB on heroku (because they don't allow those sorts of things).

To try it out, we could remote the rescue nil and see if you get a better error.

Assuming that's the case, what do you think your next move could be?

(finally, this shows why rescue nil is evil)

@jperezish
Copy link
Author

@jwo this is a tough one to sort out. I've been researching the whole topic around heroku and postgres and the best way to set to connect and seed a DB with Sinatra and Active Record. So I removed the rescue nil as you recommended and then came across using rescue ActiveRecord::StatementInvalid from this post with the same error message. Now I have a more meaningful active record error message (vs the rather cryptic pg one).

ActiveRecord::RecordNotFound at /adventure/my_game
Couldn't find all Pages with IDs (1, 3) (found 0 results, but was looking for 2)

So now I'll sort through this bit.

@jwo
Copy link
Member

jwo commented Jan 30, 2014

COOL, ok, so your data isn't there -- the pages don't exist. If you do Page.find(723423), it'll through that.

Rails will typically through a 404 here, but you'll need to handle that yourself in Sinatra.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants