I feel like I must be missing something obvious, but I can''t get rails to see the tables in my database. I''ve created the appropriate table; it has an id column set to auto_increment; and in one case it has data already, while in the other it doesn''t. The database is MySQL 4.1, and I''m running on Mac OS X 10.4.1. When I try script/ generate scaffold <tablename>, I get: Before updating scaffolding from new DB schema, try creating a table for your model (<tablename>) Any idea what the problem might be? Thanks.
Never mind. It was a singular/plural issue. Out of curiosity, is there a way to create scaffolding for a model, view, and controller that don''t connect to a database table? --Dave On Jun 16, 2005, at 9:00 AM, David Feldman wrote:> I feel like I must be missing something obvious, but I can''t get > rails to see the tables in my database. I''ve created the > appropriate table; it has an id column set to auto_increment; and > in one case it has data already, while in the other it doesn''t. The > database is MySQL 4.1, and I''m running on Mac OS X 10.4.1. When I > try script/generate scaffold <tablename>, I get: > > Before updating scaffolding from new DB schema, try creating a > table for your model (<tablename>) > > Any idea what the problem might be? > > Thanks. > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
David Feldman said:> Any idea what the problem might be?if you tableis called users i guess you have to pass User as an argument to the generator script instead of users. pietro. -- "Educators, generals, dieticians, psychologists, and parents program. Armies, students, and some societies are programmed." --Harold Abelson and Gerald Jay Sussman with Julie Sussman, "Structure and Interpretation of Computer Programs"
I am having the same problem on the same platform and feeling foolish, but I can''t determine the problem. I have a table called file_types in my db, and I issue the command generate scaffold FileType Admin. Always comes back with the "Before updating scaffolding from new DB schema, try creating a table for your model (FileType). I guess I am missing something obvious here, but beats me what it is. Can anyone point me in the right direction? Thanks, Peter David Feldman wrote:> Never mind. It was a singular/plural issue. > > Out of curiosity, is there a way to create scaffolding for a model, > view, and controller that don''t connect to a database table? > > --Dave > > On Jun 16, 2005, at 9:00 AM, David Feldman wrote: > >> I feel like I must be missing something obvious, but I can''t get >> rails to see the tables in my database. I''ve created the appropriate >> table; it has an id column set to auto_increment; and in one case it >> has data already, while in the other it doesn''t. The database is >> MySQL 4.1, and I''m running on Mac OS X 10.4.1. When I try >> script/generate scaffold <tablename>, I get: >> >> Before updating scaffolding from new DB schema, try creating a table >> for your model (<tablename>) >> >> Any idea what the problem might be? >> >> Thanks. >> >> _______________________________________________ >> Rails mailing list >> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org >> http://lists.rubyonrails.org/mailman/listinfo/rails >> > > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >
Ok lets do some variable substitution shall we - lets replace all instances of file with x and type with y so we have a table name of x_ys and we call generate scaffold xy and the system replies maybe you need table xy hmmmmmmmmmmm......... Maybe you need to call generate scaffold x_ys???? (or generate scaffold file_types if we reverse the substitution) :) The other option would be to temporarily create a table xy with the correct columns - scaffold that and then use set_table_name to switch it out afterwards. -- John W Higgins wishdev-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Well, I already tried generate scaffold file_types, and interestingly, it came back with exactly the same message (including "your model (FileTypes)". :-) I''m just getting started with this stuff, and have been using the examples from the beta book on linux. Had no problems over there, and the depot app generated correctly etc. I am still obviously missing something fundamental here about naming or something. Think I''ll go try out the same app on my linux box! Thanks for your reply. John Higgins wrote:>Ok lets do some variable substitution shall we - lets replace all >instances of file with x and type with y > >so we have a table name of x_ys > >and we call generate scaffold xy and the system replies maybe you need table xy > >hmmmmmmmmmmm......... > >Maybe you need to call generate scaffold x_ys???? (or generate >scaffold file_types if we reverse the substitution) :) > >The other option would be to temporarily create a table xy with the >correct columns - scaffold that and then use set_table_name to switch >it out afterwards. > >
Well, I''ll give that a shot and see what happens. I decided to try out the depot app over on my mac, and I get exactly the same error when generating the scaffold for that. So, I believe I have some OS X setup woes. I was having problems trying to move stuff to OS X yesterday, getting complaints about nil objects and things, so I rebuilt Tiger from scratch, applied the ruby fix for OS X, installed rails and mysql etc. So, after all that, I got rid of that problem only to get a new one. Lol, this is the first time I have had more trouble setting up something for OS X vs Linux. Maybe I should just stay on Linux (but I''d prefer to be playing on my mac). Cheers John Higgins wrote:>On 7/12/05, Peter Bailey <peterbailey-50Tl3stVsbtoOWInPp7Gjg@public.gmane.org> wrote: > > >>Well, I already tried generate scaffold file_types, and interestingly, >>it came back with exactly the same message (including "your model >>(FileTypes)". :-) >> >> >> >I have found that you might find life better going with my second >option of creating the temp table to get your scaffold setup and then >switch out the table name afterwards. Rails is a little quirky with >it''s naming conventions and you just have to do simple workarounds at >times. > > > >
Well, solved my problem, so in case this helps anyone else, here is what I did. (I should have previously noticed the build complaints for the mysql gem, but I looked at the end of the make and it said it was successfully installed - my mistake - Doh) Had to use gcc 3.3 instead of 4 to build the mysql gem so: sudo gcc_select 3.3 Then: sudo gem install mysql -- --with-mysql-config Life is now good on my mac and the scaffold generates properly etc. TextMate here I come :) Cheers Peter Bailey wrote:> Well, I''ll give that a shot and see what happens. I decided to try out > the depot app over on my mac, and I get exactly the same error when > generating the scaffold for that. So, I believe I have some OS X setup > woes. I was having problems trying to move stuff to OS X yesterday, > getting complaints about nil objects and things, so I rebuilt Tiger > from scratch, applied the ruby fix for OS X, installed rails and mysql > etc. So, after all that, I got rid of that problem only to get a new one. > > Lol, this is the first time I have had more trouble setting up > something for OS X vs Linux. Maybe I should just stay on Linux (but > I''d prefer to be playing on my mac). > > Cheers > > > John Higgins wrote: > >> On 7/12/05, Peter Bailey <peterbailey-50Tl3stVsbtoOWInPp7Gjg@public.gmane.org> wrote: >> >> >>> Well, I already tried generate scaffold file_types, and interestingly, >>> it came back with exactly the same message (including "your model >>> (FileTypes)". :-) >>> >>> >> >> I have found that you might find life better going with my second >> option of creating the temp table to get your scaffold setup and then >> switch out the table name afterwards. Rails is a little quirky with >> it''s naming conventions and you just have to do simple workarounds at >> times. >> >> >> >> > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails > >