Overriding association form column

4 views
Skip to first unread message

samson78

unread,
Sep 8, 2008, 5:57:38 AM9/8/08
to ActiveScaffold : Ruby on Rails plugin
Well, I am not even sure if the title is correct. Anyway, here is my
problem:
I have an AS named hotels. It has a "has_and_belongs_many relation
with Areas. And Areas belongs_to Categories, (areas have category_id
as foreign key).
Now, I want to be able when I click edit on a hotel to be able to view
under the Areas portion of the update form the following:
1)Category ID 1 (a label, not a field) ---- dropdown menu with all
areas in category ID 1
2)Category ID 2 ---- dropdown menu with all areas in category ID 2
3)Category ID 3 ---- dropdown menu with all areas in category ID 3

And when I hit update, Hotel will be updated with all three areas.

I have reach only up to the point that I have to use a
_areas_form_column.html.erb to override the defaults. But could
someone please tell me what to actually put in the file?

Thanks in advance,

Kostas


Ed W

unread,
Sep 9, 2008, 8:01:27 AM9/9/08
to actives...@googlegroups.com

Stop thinking that AS is some kind of magic - it's just scaffolding for
creating a form. *YOU* have to write the form though if you want any
kind of magic in it

In this case you want the form to change in response to you clicking
some parts of it. This is going to require some javascript. First make
the form work the way you want it by creating it manually and then when
you have the form the way you want it, go back to AS and use the form
override to end up with the same code

Good luck!

Ed W

Reply all
Reply to author
Forward
0 new messages