So I make this ajax call:

```
$.ajax({
   type: "POST",
   url: "/videos",
   data: { title: oembed.title }
});

```

inside this function call to the Embedly API:

```
$('a.oembed').embedly({maxWidth:300,'method':'replace'}).bind('embedly-oembed', function(e, oembed){ 
});

```

Now there's two things wrong with the way this $.ajax() call is working. First, it's being calling every time I load the `index` view, which makes sense because that's where I'm pointing the url. However, I want it to be called just once when the video is created, and I don't know how to point it to just the `create` method.

Second, the ajax call is just adding an empty row to the database, and the title, which is generated dynamically by the embedly API and stored in the `oembed` hash (the selector finds the video link in my view and turns it into an embedded video, as well as stores all of the video's attributes in `oembed`), is not being inserted into my database. I'm trying to store this dynamically generated title into my database.

How do I accomplish both of these goals?

UPDATE: If you're curious and want to see this in action, fork the code here: <https://github.com/meltzerj/Dreamstill>

UPDATE 2: Here's what the console says. Note that one is for `create` and the other is for `show`:

Started POST "/videos" for 127.0.0.1 at Wed Mar 16 03:03:12 -0700 2011
 Processing by VideosController#create as 
 Parameters: {"title"=>"Exclusive: Charlie Sheen Says He's 'Not Bipolar but 'Bi-Winning' (02.28.11)"}
 AREL (0.4ms) INSERT INTO "videos" ("description", "thumbnail\_url", "released", "video\_url", "user\_id", "title", "embed\_code", "created\_at", "updated\_at") VALUES (NULL, NULL, NULL, NULL, NULL, NULL, NULL, '2011-03-16 10:03:12.277518', '2011-03-16 10:03:12.277518')
Redirected to <http://localhost:3000/videos/413>
Completed 302 Found in 17ms

Started GET "/videos/396" for 127.0.0.1 at Wed Mar 16 03:03:03 -0700 2011
 Processing by VideosController#show as 
 Parameters: {"id"=>"396"}
 Video Load (0.2ms) SELECT "videos".\* FROM "videos" WHERE "videos"."id" = 396 LIMIT 1
Rendered videos/\_show\_video.html.erb (6.4ms)
Rendered videos/show.html.erb within layouts/application (9.8ms)
Completed 200 OK in 33ms (Views: 24.5ms | ActiveRecord: 0.2ms)