Running ruby script/generate scaffold Product Admin is a wonderful way to set up well, exactly what it says, a scaffold. My problem is that I have several other tables that are linked, through foreign keys, to the Product table. Say an "authors" table. Now when I go enter a new product, a book, I want the application to provide a drop down list of authors generated from the records in the authors table and let me choose an author when I enter my other book details. I also want the application to allow me to administer the authors table to CRUD authors. I know that I can start off as above and do lots of copy/past and search/replace of/in the MVC tree to provide CRUD for authors and list them in the new product view, but I''d rather use any functionality that Rails might have to auto generate these. Can/should I run ruby script/generate scaffold <entity> Admin for each entity in my schema? Bealach -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/a61c5533/attachment.html
You want ruby script/generate model <modelname: like "author">. What this will do: create the basic code that will link to the appropriate MySQL table. What this won''t do: create new controller code, and a bunch of new view pages. I think this is what you want. -Adam -- Posted via http://www.ruby-forum.com/.
Hi Adam, Thanks very much for your comments. I obviously have not quite understood Rails yet. Why does it not generate the contorller/view code? It does such a nice job of setting things up for the admin, why not provide the same framework for each model? Bealach On 4/5/06, Adam Bloom <admanb@gmail.com> wrote:> > You want ruby script/generate model <modelname: like "author">. > > What this will do: create the basic code that will link to the > appropriate MySQL table. > > What this won''t do: create new controller code, and a bunch of new view > pages. > > I think this is what you want. > > -Adam > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/96ebc320/attachment.html
Bealach Na Bo wrote:> Hi Adam, > > Thanks very much for your comments. I obviously have not quite > understood > Rails yet. Why does it not generate the contorller/view code? It does > such a > nice job of setting things up for the admin, why not provide the same > framework for each model? > > BealachNow I realize I''ve misread your post. Very sorry.>Can/should I run ruby script/generate scaffold <entity> Admin for each >entity in my schema?In fact, this is exactly what you should do. :) -Adam -- Posted via http://www.ruby-forum.com/.
>>Can/should I run ruby script/generate scaffold <entity> Admin for each >>entity in my schema? > > In fact, this is exactly what you should do. :)So: ruby script/generate scaffold Product Admin>My problem is that I have several other tables that are linked, >through foreign keys, to the Product table. Say an "authors" table.Now if Bealach''s scaffold looks like mine, author_id is not a recognized field; I have no way to edit author_id in existing records and no way to add it to new records. So I try: ruby script/generate scaffold Author Admin which replaces the preceding scaffold (Product) with an entirely new one (Author), but does not appear to combine or link the models. -- Posted via http://www.ruby-forum.com/.
And it won''t. Here''s what I do (it won''t work for depot) but it will work for your own app) ruby script/generate scaffold Product admin/product ruby script/generate scaffold Author admin/author Then make a route that maps /admin/ to a specific controller map.connect ''/admin'', :controller=>"/admin/proudct", :action=>"index" Then it''s just a matter of making a menu that links things around using link_to or named routes. On 4/5/06, Justin Skolnick <justin@revision8.com> wrote:> > >>Can/should I run ruby script/generate scaffold <entity> Admin for each > >>entity in my schema? > > > > In fact, this is exactly what you should do. :) > > So: > ruby script/generate scaffold Product Admin > > >My problem is that I have several other tables that are linked, > >through foreign keys, to the Product table. Say an "authors" table. > > Now if Bealach''s scaffold looks like mine, author_id is not a recognized > field; I have no way to edit author_id in existing records and no way to > add it to new records. > > So I try: > ruby script/generate scaffold Author Admin > > which replaces the preceding scaffold (Product) with an entirely new one > (Author), but does not appear to combine or link the models. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/c1d46e35/attachment.html
Hi guys, On 4/5/06, Justin Skolnick <justin@revision8.com> wrote:> > //>>Can/should I run ruby script/generate scaffold <entity> Admin for each > //>>entity in my schema? > //> > //> In fact, this is exactly what you should do. :) > // > //So: > //ruby script/generate scaffold Product Admin > // > //>My problem is that I have several other tables that are linked, > //>through foreign keys, to the Product table. Say an "authors" table. > // > //Now if Bealach''s scaffold looks like mine, author_id is not a recognized > //field; I have no way to edit author_id in existing records and no way to > //add it to new records.On this point I was helped by Charlie Bowman''s answer to an earlier post of mine (almost identical to yours Justin). So I quote, "You can always edit the .rhtml files to include any fields that are not showing. By default the primary fields and foreign key aren''t shown when you scaffold a table." //> //So I try: > //ruby script/generate scaffold Author Admin > // > //which replaces the preceding scaffold (Product) with an entirely new one > //(Author), but does not appear to combine or link the models. > //Correct, and this is where I was hoping I could be lazy and find a way to let Rails produce lots of nice code for me. Alas, I have not found a way and have ended up with the following solution: $> ruby script/generate scaffold Product Admin to get my "main" entry point edited the the _form.rhtml file to add the missing author_id field for user entry $>ruby script/generate controller Author list new create destroy <and any other methods that I might want> to get a bunch of very basic files like author_controller.rb that has all my method with empty bodies edited the rest by hand :| Of course, you have start writing code at some stage, I was just hoping I could get more for free :) Bealach> //-- > //Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/8a3aadf1/attachment.html
Hi Brian, Your comments are very welcome, but I only found them by chance since I only read the stuff I get in gmail from lists.rubyonrails.org, that''s why, I seem to be totally ignoring what you point out in my previous posting....sorry :) Bealach Brian Hogan wrote:> And it won''t. > > Here''s what I do (it won''t work for depot) but it will work for your own > app) > > ruby script/generate scaffold Product admin/product > ruby script/generate scaffold Author admin/author > > Then make a route that maps /admin/ to a specific controller > > map.connect ''/admin'', :controller=>"/admin/proudct", :action=>"index" > > Then it''s just a matter of making a menu that links things around using > link_to or named routes.-- Posted via http://www.ruby-forum.com/.
:) Technology rocks, doesn''t it? On 4/5/06, Guest <bealach@gmail.com> wrote:> > Hi Brian, > > Your comments are very welcome, but I only found them by chance since I > only read the stuff I get in gmail from lists.rubyonrails.org, that''s > why, I seem to be totally ignoring what you point out in my previous > posting....sorry :) > Bealach > > Brian Hogan wrote: > > And it won''t. > > > > Here''s what I do (it won''t work for depot) but it will work for your own > > app) > > > > ruby script/generate scaffold Product admin/product > > ruby script/generate scaffold Author admin/author > > > > Then make a route that maps /admin/ to a specific controller > > > > map.connect ''/admin'', :controller=>"/admin/proudct", :action=>"index" > > > > Then it''s just a matter of making a menu that links things around using > > link_to or named routes. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060405/f5e83f02/attachment.html
OK Brian''s way of doing it works nicely, but my scaffold.css is somehow ignored by all the views even though every layout has the line <%= stylesheet_link_tag ''scaffold'' %> I thought scaffold.css in <app root>/public/stylesheets would be loaded by all views... Any ideas? Bealach On 4/5/06, Guest <bealach@gmail.com> wrote:> > Hi Brian, > > Your comments are very welcome, but I only found them by chance since I > only read the stuff I get in gmail from lists.rubyonrails.org, that''s > why, I seem to be totally ignoring what you point out in my previous > posting....sorry :) > Bealach > > Brian Hogan wrote: > > And it won''t. > > > > Here''s what I do (it won''t work for depot) but it will work for your own > > app) > > > > ruby script/generate scaffold Product admin/product > > ruby script/generate scaffold Author admin/author > > > > Then make a route that maps /admin/ to a specific controller > > > > map.connect ''/admin'', :controller=>"/admin/proudct", :action=>"index" > > > > Then it''s just a matter of making a menu that links things around using > > link_to or named routes. > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060406/b339b850/attachment.html
Bealach Na Bo wrote:> OK Brian''s way of doing it works nicely, but my scaffold.css is somehow > ignored by all > the views even though every layout has the line > > <%= stylesheet_link_tag ''scaffold'' %> > > I thought scaffold.css in <app root>/public/stylesheets would be loaded > by all views...View the source for your rendered html. What is the stylesheet link? -- Ray
On 4/6/06, Ray Baxter <ray@warmroom.com> wrote:> > Bealach Na Bo wrote: > > OK Brian''s way of doing it works nicely, but my scaffold.css is somehow > > ignored by all > > the views even though every layout has the line > > > > <%= stylesheet_link_tag ''scaffold'' %> > > > > I thought scaffold.css in <app root>/public/stylesheets would be loaded > > by all views... > > > View the source for your rendered html. What is the stylesheet link? > > -- > > RayHi Ray, There just ain''t any! It''s very odd. For each model, I have a directory under app/views/admin where things like list.rhtml new.rhtml show.rhtml live corresponding to each of the models, I have a layout in app/views/layouts In every layout, I have <%= stylesheet_link_tag ''scaffold'' %> finally, I have public/stylesheets/scaffold.css which is not loaded in to any of the rendered views! Bealach _______________________________________________> Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060406/a1a77b7c/attachment.html
You might want to look into http://wiki.rubyonrails.org/rails/pages/Scaffolding+Extensions+Plugin On 07/04/06, Ray Baxter <ray@warmroom.com> wrote:> Bealach Na Bo wrote: > > OK Brian''s way of doing it works nicely, but my scaffold.css is somehow > > ignored by all > > the views even though every layout has the line > > > > <%= stylesheet_link_tag ''scaffold'' %> > > > > I thought scaffold.css in <app root>/public/stylesheets would be loaded > > by all views... > > > View the source for your rendered html. What is the stylesheet link? > > -- > > Ray > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
On 4/7/06, David Mitchell <monch1962@gmail.com> wrote:> > You might want to look into > http://wiki.rubyonrails.org/rails/pages/Scaffolding+Extensions+Plugin > > On 07/04/06, Ray Baxter <ray@warmroom.com> wrote: > > Bealach Na Bo wrote: > > > OK Brian''s way of doing it works nicely, but my scaffold.css is > somehow > > > ignored by all > > > the views even though every layout has the line > > > > > > <%= stylesheet_link_tag ''scaffold'' %> > > > > > > I thought scaffold.css in <app root>/public/stylesheets would be > loaded > > > by all views... > > > > > > View the source for your rendered html. What is the stylesheet link? > > > > -- > > > > Ray > > > > _______________________________________________ > > Rails mailing list > > Rails@lists.rubyonrails.org > > http://lists.rubyonrails.org/mailman/listinfo/rails > > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >Thanks David! It looks VERY interesting. I''ll have to dig into it... Bealach -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060406/b58bce76/attachment.html