Hi all, thanks in advance for any help
I am writing a database interface, very basic stuff really. But I'm essentially a newbie and I've realised it's not easy to poorly design your application with RoR, where I would of probably used some funky looking logic with SQL with PHP for example. I'm a bit lost with how to structure it in Rails.
Basicly, it is a database for a business that has to store information aboout Councils, Project Builders and fees respectively. For each council there is static fees, but for each Project Builder there is fees that are unique to each Council.
I want the data to be displayed by, Council displaying all the static council fees. (Easy part, got that working fine.) And for each Project Builder to display a list of Councils and their respective fees (which are unique to that council for that builder. Quite baffled here.)
I was thinking, to have a table for each Project Builder, with Council as the unique ID. But I don't know how to let the user create a table with RoR, and then be able to populate it with rows.
Thanks for any advice, this has been driving me crazy for days.
Something along the lines of..
a single fees table
council_id project_builder_id fee fee_name
I'm not sure how you want to display the data... but from the project_builder page you can easily show all council fees and other way around from the council show page..
Sometimes I'm better with straight up code to understanding questions then english.. feel free to post some snippets and I'll expand a little more..
(you would never want to allow users to create their own tables... thats really not DRY and would get hairy fast)
Just a quick peek in; you have three Objects here, a Council, Builder, and Fee.
councils: id, name, fee_name_1, fee_amount_1, etc... builders: id, name, etc... fees: id, council_id, builder_id, fee_name, fee_amount
In the Council model: has_many: fees
In Builder model: has_many: fees
In Fee model: belongs_to: council belongs_to: builder
With these associations you'll be able to traverse from object to object as such: council = Council.find(1)
for fee in council.fees puts fee.builder.name puts fee.fee_amount end
Hope this helps!