[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.ruby

Use of scaffolding in the ONLamp Rails tutorial

Lyle Johnson

1/21/2005 10:27:00 PM

I'm going through Curt's excellent Rails tutorial (at
http://www.onlamp.com/pub/a/onlamp/2005/01/20/...) and getting
stuck around the point that I try to add a new row to the recipes
table by clicking the "Create" button. It seems like the basic
"scaffolding" approach isn't doing the right thing, because it never
adds a row to the database for the newly created recipe(s). Just
curious if anyone else is having trouble at this point in the
tutorial?


9 Answers

Lyle Johnson

1/22/2005 2:11:00 AM

0

I'm going through Curt's excellent Rails tutorial (at
http://www.onlamp.com/pub/a/onlamp/2005/01/20/...) and getting
stuck around the point that I try to add a new row to the recipes
table by clicking the "Create" button. It seems like the basic
"scaffolding" approach isn't doing the right thing, because it never
adds a row to the database for the newly created recipe(s). Just
curious if anyone else is having trouble at this point in the
tutorial?


David Heinemeier Hansson

1/22/2005 12:07:00 PM

0

> I'm going through Curt's excellent Rails tutorial (at
> http://www.onlamp.com/pub/a/onlamp/2005/01/20/...) and getting
> stuck around the point that I try to add a new row to the recipes
> table by clicking the "Create" button. It seems like the basic
> "scaffolding" approach isn't doing the right thing, because it never
> adds a row to the database for the newly created recipe(s). Just
> curious if anyone else is having trouble at this point in the
> tutorial?

Have a look in the log by doing something like "tail -f
log/development.log" -- then you'll be able to see all the SQL
statements being fired off and whether the request is coming in right.

If you have additional questions, please do come hang out on
#rubyonrails for real-time assistance or use the dedicated Rails
mailing list. You can read more about both on
http://wiki.rubyo....

Welcome to the Rails world!
--
David Heinemeier Hansson,
http://www.basec... -- Web-based Project Management
http://www.rubyon... -- Web-application framework for Ruby
http://macro... -- TextMate: Code and markup editor (OS X)
http://www.loudthi... -- Broadcasting Brain



Lyle Johnson

1/22/2005 4:01:00 PM

0

On Sat, 22 Jan 2005 21:06:42 +0900, David Heinemeier Hansson
<david@loudthinking.com> wrote:

> Have a look in the log by doing something like "tail -f
> log/development.log" -- then you'll be able to see all the SQL
> statements being fired off and whether the request is coming in right.

I tried this before posting; the SQL statements (e.g. to INSERT the
new row(s) into the database) are never getting printed out.

> If you have additional questions, please do come hang out on
> #rubyonrails for real-time assistance or use the dedicated Rails
> mailing list. You can read more about both on
> http://wiki.rubyo....

I had been chatting with several of the guys on #rubyonrails about
this problem before finally giving in and posting a query here. ;) You
are of course correct that they were really helpful, and that's a good
resource for anyone to check out. We just weren't able to track down
the problem.

We *did* note that when I went out to the console and tried
instantiating a new Recipe object and then calling its save() method,
it *did* get added to the database; so the AR layer certainly seems to
be doing the right thing. Indeed, the form that was displayed in the
web browser (when I visited the recipe/new page) showed all of the
expected fields -- so it was getting the correct table description
from the database. But something was definitely breaking down when I'd
click the "Create" button. No *errors* were printed to
development.log; it's just that it didn't do what it was supposed to
do.

> Welcome to the Rails world!

Thanks! After talking with the guys on #rubyonrails, it sounds like I
ultimately won't want to depend on the "scaffolding" feature anyways,
and so I regard this as just a temporary hiccup in my getting started.
I'm looking forward to learning more about how to use Rails over the
next few weeks. I was mainly checking in to see if, by chance, anyone
else had run into this particular problem with Curt's tutorial.

P.S. Apologies for the duplicate post that kicks off this thread.
There was an unusual delay before the first one showed up, and so I'd
resubmitted it to ruby-talk in the meantime...


timsuth

1/22/2005 10:15:00 PM

0

In article <d4cf71b00501211426228c462a@mail.gmail.com>, Lyle Johnson wrote:
>I'm going through Curt's excellent Rails tutorial (at
>http://www.onlamp.com/pub/a/onlamp/2005/01/20/...) and getting
>stuck around the point that I try to add a new row to the recipes
>table by clicking the "Create" button. It seems like the basic
>"scaffolding" approach isn't doing the right thing, because it never
>adds a row to the database for the newly created recipe(s). Just
>curious if anyone else is having trouble at this point in the
>tutorial?

It worked for me.

bananafishbones

1/23/2005 12:33:00 AM

0

On Sun, 23 Jan 2005 07:15:56 +0900, Tim Sutherland <timsuth@ihug.co.nz> wrote:
> In article <d4cf71b00501211426228c462a@mail.gmail.com>, Lyle Johnson wrote:
> >I'm going through Curt's excellent Rails tutorial (at
> >http://www.onlamp.com/pub/a/onlamp/2005/01/20/...) and getting
> >stuck around the point that I try to add a new row to the recipes
> >table by clicking the "Create" button. It seems like the basic
> >"scaffolding" approach isn't doing the right thing, because it never
> >adds a row to the database for the newly created recipe(s). Just
> >curious if anyone else is having trouble at this point in the
> >tutorial?
>
> It worked for me.
>
>
Is it throwing an error at you? Make sure you've got the db set up
correcty - I had a problem using phpMyAdmin until I realized that id
needed to be set to auto_increment.


Lyle Johnson

1/23/2005 2:54:00 AM

0

On Sun, 23 Jan 2005 09:33:16 +0900, bananafishbones
<banano.fisi.ostos@gmail.com> wrote:

> Is it throwing an error at you? Make sure you've got the db set up
> correcty - I had a problem using phpMyAdmin until I realized that id
> needed to be set to auto_increment.

It wasn't throwing an error -- or, at the least, no error messages
were getting written to the development.log file. And as I mentioned
in an earlier message, the ActiveRecord layer does seem to do the
right thing in terms of inserting the new row into the database *if* I
use it outside of the Web application. So I think the database is
probably set up correctly.


Curt Hibbs

1/23/2005 8:34:00 AM

0

Lyle Johnson wrote:
>
> On Sun, 23 Jan 2005 09:33:16 +0900, bananafishbones
> <banano.fisi.ostos@gmail.com> wrote:
>
> > Is it throwing an error at you? Make sure you've got the db set up
> > correcty - I had a problem using phpMyAdmin until I realized that id
> > needed to be set to auto_increment.
>
> It wasn't throwing an error -- or, at the least, no error messages
> were getting written to the development.log file. And as I mentioned
> in an earlier message, the ActiveRecord layer does seem to do the
> right thing in terms of inserting the new row into the database *if* I
> use it outside of the Web application. So I think the database is
> probably set up correctly.

Perhaps the problem is your browser caching the pages. Try forcing a page
re-load. or exiting and restarting your browser.

Curt



Lyle Johnson

1/24/2005 4:09:00 PM

0

On Sun, 23 Jan 2005 17:34:20 +0900, Curt Hibbs <curt@hibbs.com> wrote:

> Perhaps the problem is your browser caching the pages. Try forcing a page
> re-load. or exiting and restarting your browser.

I think I just now figured out what I was doing wrong. I was
mistakenly typing the controller name in uppercase letters, e.g.

http://localhost:3000/Recipe/new

instead of:

http://localhost:3000/recipe/new

In the former case, there's no error message (that was obvious to me)
printed to the development.log file -- other than, of course, the
application didn't behave as expected. ;)

I do not know enough about Rails yet to know if this is the kind of
error which Rails could have automatically detected and warned me
about. If nothing else, this might be a good one to add to the
"gotchas" list for Rails, if there is such a thing. ;)
Lyle


Curt Hibbs

1/24/2005 7:43:00 PM

0

Lyle Johnson wrote:
>
> On Sun, 23 Jan 2005 17:34:20 +0900, Curt Hibbs <curt@hibbs.com> wrote:
>
> > Perhaps the problem is your browser caching the pages. Try
> forcing a page
> > re-load. or exiting and restarting your browser.
>
> I think I just now figured out what I was doing wrong. I was
> mistakenly typing the controller name in uppercase letters, e.g.
>
> http://localhost:3000/Recipe/new
>
> instead of:
>
> http://localhost:3000/recipe/new
>
> In the former case, there's no error message (that was obvious to me)
> printed to the development.log file -- other than, of course, the
> application didn't behave as expected. ;)
>
> I do not know enough about Rails yet to know if this is the kind of
> error which Rails could have automatically detected and warned me
> about. If nothing else, this might be a good one to add to the
> "gotchas" list for Rails, if there is such a thing. ;)

Yeah, I just recently became aware of this myself. I'll probably say
something about in part 2 of the tutorial.

Curt