Like with simple table editing, there are also typical ways of how a user usually interacts with one-to-many or many-to-many relations. For example, one would show the fields of one row of table1 in the screen and below a line-by-line view of all associated entries in table2. Then, one could press an "Edit" button and add or delete rows from table2 to this entry of table1, effectively modifying the join table and maybe also additional fields in the join table. Having seen what scaffolding can do for single table edits, I am wondering if there are generators for this kind of interface to one-to-many and many-to-many relationships too? -- Posted via http://www.ruby-forum.com/.
Jeremy Evans
2006-Jan-12 17:34 UTC
[Rails] Scaffolding support for many-to-many editing (habtm)?
On 1/12/06, RHaus <roman.hausner@gmail.com> wrote:> Like with simple table editing, there are also typical ways of how a > user usually interacts with one-to-many or many-to-many relations. For > example, one would show the fields of one row of table1 in the screen > and below a line-by-line view of all associated entries in table2. Then, > one could press an "Edit" button and add or delete rows from table2 to > this entry of table1, effectively modifying the join table and maybe > also additional fields in the join table. > > Having seen what scaffolding can do for single table edits, I am > wondering if there are generators for this kind of interface to > one-to-many and many-to-many relationships too?The Scaffolding Extensions plugin has a habtm scaffolder (with a interface simpler than what you describe). It doesn''t work with the scaffold generator though.
RHaus
2006-Jan-13 10:22 UTC
[Rails] Re: Scaffolding support for many-to-many editing (habtm)?
Jeremy Evans wrote:> On 1/12/06, RHaus <roman.hausner@gmail.com> wrote: >> one-to-many and many-to-many relationships too? > The Scaffolding Extensions plugin has a habtm scaffolder (with a > interface simpler than what you describe). It doesn''t work with the > scaffold generator though.That sounds very good, but I am afraid I am too much of a newbie to understand how to make use of it? Could you explain how to proceed or where to get more information? -- Posted via http://www.ruby-forum.com/.
Jeremy Evans
2006-Jan-13 18:36 UTC
[Rails] Re: Scaffolding support for many-to-many editing (habtm)?
On 1/13/06, RHaus <roman.hausner@gmail.com> wrote:> Jeremy Evans wrote: > > On 1/12/06, RHaus <roman.hausner@gmail.com> wrote: > >> one-to-many and many-to-many relationships too? > > The Scaffolding Extensions plugin has a habtm scaffolder (with a > > interface simpler than what you describe). It doesn''t work with the > > scaffold generator though. > > That sounds very good, but I am afraid I am too much of a newbie to > understand how to make use of it? Could you explain how to proceed or > where to get more information?See http://wiki.rubyonrails.org/rails/pages/Plugins for more information about plugins. The Scaffolding Extension plugin is currently only available via subversion, so you''d need that installed (or contact me offlist and I''ll send it to you). After the plugin is installed, given appropriately named models, you''d do something like this in a controller: scaffold(:category, :habtm=>:forms) You go to the edit page of the category and there is a link to a page that does habtm scaffolding for the forms of a given category (edit_category_forms/:id). If you just want habtm scaffolding without other scaffolding, you can just use: scaffold_habtm(:category, :form) Then you can go to either edit_category_forms/42 to edit forms for the category with the id of 42 or edit_form_categories/42 to edit categories for the form with the id of 42. See the RDoc of the plugin for more details and options. I''ll try to work on better introductory documentation soon.
Roman Hausner
2006-Jan-16 13:27 UTC
[Rails] Re: Re: Scaffolding support for many-to-many editing (habtm)
Jeremy Evans wrote:> On 1/13/06, RHaus <roman.hausner@gmail.com> wrote: >> Jeremy Evans wrote: >> > On 1/12/06, RHaus <roman.hausner@gmail.com> wrote: >> >> one-to-many and many-to-many relationships too? >> > The Scaffolding Extensions plugin has a habtm scaffolder (with a >> > interface simpler than what you describe). It doesn''t work with the >> > scaffold generator though. >> >> That sounds very good, but I am afraid I am too much of a newbie to >> understand how to make use of it? Could you explain how to proceed or >> where to get more information? > > See http://wiki.rubyonrails.org/rails/pages/Plugins for more > information about plugins. The Scaffolding Extension plugin is > currently only available via subversion, so you''d need that installed > (or contact me offlist and I''ll send it to you). After the plugin is > installed,Thank you for your patient help! I was able to receive the plugin and have now a directory scaffolding_extensions locally. However I cannot figure out how to install it properly. I tried copying this directory to vendor/plugins in my rails directory, but I keep getting the error message "Unknown key(s): habtm" whenever I add the :habtm keyword to the scaffold command. I also tried to copy the content of the plugin folder to the root rails folder, but this did not work either. Unfortunately I could not find information about how to properly install a plugin on the wiki page either, so I am a bit lost here still ...> given appropriately named models, you''d do something like > this in a controller: > > scaffold(:category, :habtm=>:forms) > > You go to the edit page of the category and there is a link to a page > that does habtm scaffolding for the forms of a given category > (edit_category_forms/:id). > > If you just want habtm scaffolding without other scaffolding, you can > just use: > > scaffold_habtm(:category, :form) > > Then you can go to either edit_category_forms/42 to edit forms for the > category with the id of 42 or edit_form_categories/42 to edit > categories for the form with the id of 42. >This looks very much like what I would like Rails to do! I am wondering about the relationship between the "scaffold ..." command (which is extended by the plugin you pointed out to me) and the generator script -- is there some kind of automatic relationship so that anything that works with "scaffold" will also be accessible to the generator or has this to be implemented in parallel? -- Posted via http://www.ruby-forum.com/.
Roman Hausner
2006-Jan-16 16:04 UTC
[Rails] Re: Re: Scaffolding support for many-to-many editing (habtm)
UPDATE: it seems some of the problems above are the result from old files that still existed, so I started afresh with an empty rails application. I figured out that in order to install the plugin, I need to do: ruby script/plugin install svn://suven.no-ip.org/rails/plugins/scaffolding_extensions I then created just two models where I added "has_and_belongs_to_many <othermodelname>s" and two controllers where I added "scaffold :thismodelname, :habtm=>:othermodelname" Now I do get the new "manage <Modelname" screen and I do get a new link for "Associate Records ... "othermodel" in the edit screen. However when I click this link, I get the error "Unknown action / No action responded to edit_thismodel_othermodels" So it seems I am missing one crucial step here ... -- Posted via http://www.ruby-forum.com/.
Jeremy Evans
2006-Jan-16 23:55 UTC
[Rails] Re: Re: Scaffolding support for many-to-many editing (habtm)
On 1/16/06, Roman Hausner <roman.hausner@gmail.com> wrote:> UPDATE: it seems some of the problems above are the result from old > files that still existed, so I started afresh with an empty rails > application. > > I figured out that in order to install the plugin, I need to do: > ruby script/plugin install > svn://suven.no-ip.org/rails/plugins/scaffolding_extensions > > I then created just two models where I added "has_and_belongs_to_many > <othermodelname>s" > > and two controllers where I added "scaffold :thismodelname, > :habtm=>:othermodelname" > > Now I do get the new "manage <Modelname" screen and I do get a new link > for "Associate Records ... "othermodel" in the edit screen. > However when I click this link, I get the error "Unknown action / No > action responded to edit_thismodel_othermodels" > > So it seems I am missing one crucial step here ...It sounds like you did everything correct. By any chance did you do: scaffold :thismodelname, :habtm=>:othermodelnames # Notice plural I looked at the code and it doesn''t attempt to singularize the model names that are given in habtm nor does it check that the habtm scaffold was actually created before it adds the links (bad me). Both should be easy to fix. Please let me know whether that was the problem.
RHaus
2006-Jan-17 11:50 UTC
[Rails] Re: Re: Re: Scaffolding support for many-to-many editing (ha
Jeremy Evans wrote:> On 1/16/06, Roman Hausner <roman.hausner@gmail.com> wrote: >> >> and two controllers where I added "scaffold :thismodelname, >> :habtm=>:othermodelname" >> >> Now I do get the new "manage <Modelname" screen and I do get a new link >> for "Associate Records ... "othermodel" in the edit screen. >> However when I click this link, I get the error "Unknown action / No >> action responded to edit_thismodel_othermodels" >> >> So it seems I am missing one crucial step here ... > > It sounds like you did everything correct. By any chance did you do: > > scaffold :thismodelname, :habtm=>:othermodelnames # Notice plural >Originally, yes, but I got an error message that complained about a missing "Projects" already much earlier so I tried the singular form ... then, I get the "unknown action" complaint.> I looked at the code and it doesn''t attempt to singularize the model > names that are given in habtm nor does it check that the habtm > scaffold was actually created before it adds the links (bad me). Both > should be easy to fix. Please let me know whether that was the > problem.I think these were indeed the problems I encountered. :) -- Posted via http://www.ruby-forum.com/.
Jeremy Evans
2006-Jan-17 18:43 UTC
[Rails] Re: Re: Re: Scaffolding support for many-to-many editing (ha
On 1/17/06, RHaus <roman.hausner@gmail.com> wrote:> Jeremy Evans wrote: > > It sounds like you did everything correct. By any chance did you do: > > > > scaffold :thismodelname, :habtm=>:othermodelnames # Notice plural > > > Originally, yes, but I got an error message that complained about a > missing > "Projects" already much earlier so I tried the singular form ... then, > I get the "unknown action" complaint.Can you post the exact code you are using? Also, can you post the relevent parts of the source of the edit page created by the scaffold? You may want to try just generating the habtm scaffold via: scaffold_habtm(:thismodelname, :othermodelname) And seeing if that affects things. If that doesn''t work I''ll send you a modified version with some debugging code.> > I looked at the code and it doesn''t attempt to singularize the model > > names that are given in habtm nor does it check that the habtm > > scaffold was actually created before it adds the links (bad me). Both > > should be easy to fix. Please let me know whether that was the > > problem. > > I think these were indeed the problems I encountered. :)They''ll be fixed in the next revision.