11.27.07

Getting an exported heroku project working

Posted in Programming, Ruby, heroku, rails at 6:00 am by Robert Horvick

After exporting a project from heroku to do some local work there were two things I needed to do:

  1.  Create config/database.yml - it is good that this file is not exported.  It contains no details that are useful outside of the heroku environment.  But don’t forget you need it (if you don’t know what to put there - create an empty rails project and grab that one).
  2. create the databases referenced in config/database.yml
  3. Execute “rake db:sessions:create” - this will create a migration that is necessary to enable SQL session storage.
  4. Execute “rake db:migrate” - this will execute all of your migrations as well as the SQL session migration.

After this my project was working.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]

11.26.07

heroku.com + script.aculo.us = broken ajax

Posted in Programming, Ruby, ajax, heroku, rails at 4:55 pm by Robert Horvick

Update: As I expected the guys are heroku turned around a fix very quickly.  I tested autocompletion tonight and it worked perfect.  heroku + script.aculo.us = working like a champ :) 

They say that constructive criticism (e.g. complaints) should occur in a sandwich of positive thoughts.  Generally I think that’s a bunch of PC granola-farming nonsense.  People need to hear what people need to hear.  If I suck - tell me.  If I’m lucky you’ll tell me why.  If I’m really lucky you may offer advice on how to improve.

But knowing that something sucks is the baseline.

But I’m going to break my rule and go with the PC warm-fuzzy approach.

Positive: Heroku kicks ass

Rails site online fast, syntax highlighting editor, backup/restore, nginx, postgres … love it.  I’ve been able to make a lot of progress in this environment (and being able to work on the site from multiple computers is very nice).

Negative: Heroku injects some code into every response

This breaks ajax behaviors by altering partials (and includes prototype.js which breaks script.aculo.us) … in short ajaxy rails is broken.

When I make an ajax request I expect to get back something like:

<ul class="restaurants">

  <li class="restaurant">    <div class="name">rest name</div>

  </li>

  <li class="restaurant">

    <div class="name">O'Charley's</div>

  </li>

  <li class="restaurant">

    <div class="name">Sunday Deal</div>

  </li>

  <li class="restaurant">

    <div class="name">Monday Deal</div>

  </li>

  <li class="restaurant">

    <div class="name">Sunday Cheap</div>

  </li>

</ul>

But what I actually get back is:

<!-- heroku toolbar -->

<script src="http://heroku.com/javascripts/prototype.js” type=”text/javascript”></script>

<script src=”http://heroku.com/javascripts/effects.js” type=”text/javascript”></script>

<script src=”http://heroku.com/toolbar/heroku_toolbar.js” type=”text/javascript”></script>

<link href=”http://heroku.com/toolbar/heroku_toolbar.css” media=”screen” rel=”Stylesheet” type=”text/css” />

<script type=”text/javascript”>HerokuToolbar.html = ‘<div id=”heroku_toolbar”><a href=”http://heroku.com” id=”heroku_logo”></a><a href=”http://edit.kidseatfree.heroku.com/?uri=%2Fdeal%2Fauto_complete_for_restaurant_name” id=”heroku_back_button”></a><a href=”javascript:HerokuToolbar.toggle()” mce_href=”javascript:HerokuToolbar.toggle()” id=”heroku_inspect_button”></a><img id=”heroku_spinner” src=”http://heroku.com/toolbar/images/spinner.gif” style=”display: none”><span id=”heroku_login_info”><a href=”http://heroku.com/myapps”>robert.horvick@gmail.com</a> | <a href=”http://heroku.com/logout”>logout</a></span></div>’</script>

<span class=”heroku_marker heroku_start” style=”display: none”>/mnt/home/userapps/347/app/views/deal/_restaurants.rhtml</span>

<ul class=”restaurants”>

  <li class=”restaurant”>    <div class=”name”>rest name</div>

  </li>

  <li class=”restaurant”>

    <div class=”name”>O’Charley’s</div>

  </li>

  <li class=”restaurant”>

    <div class=”name”>Sunday Deal</div>

  </li>

  <li class=”restaurant”>

    <div class=”name”>Monday Deal</div>

  </li>

  <li class=”restaurant”>

    <div class=”name”>Sunday Cheap</div>

  </li>

</ul>

<span class=”heroku_marker heroku_finish” style=”display: none”></span>

Ah crap.  Now my autocomplete doesn’t render … oh but it gets worse.

Reincluding prototype.js causes the scriptaculous extending of Ajax.Autocompleter to be lost and now autocomplete events don’t fire (in fact FireBug shows an error because Ajax.Autocompleter is not a constructor).

Bug reported.

Positive: The folks at heroku kick ass

I have reported quite a few issues - some bugs, some feature ideas, some random rants about usability or business models.  But in every case these guys have turned around fixes or offered workarounds in a matter of hours. 

The issue I just described - I’m confident that they will be able to work past it quickly or provide some sort of workaround for the specific case of partials.

So there you go.

A feedback sandwich.

Now I’m hungry.

[Slashdot] [Digg] [Reddit] [del.icio.us] [Facebook] [Technorati] [Google] [StumbleUpon]