We are working with nested attributes and we've reached a point where we're not sure if there is a better, clearer, "more rails" way of dealing with it.
We have 3 models - Organisation, Category and a strictly join table CategoryOrganisation (no additional attributes). The relation between Organisation and Category is many-to-many.
Now, we want to create a form with checkboxes through which the categories for organisations can be added and removed. The example form would look like that:
Now, the form should behave like that:
new
action is hit, it should show all categories - unchecked,create
action is hit, but validations are not passing it should render the new
view, but keeping the checkboxes that were selected,edit
action is hit, is should show all categories and current categories of the edited organisation should be checked,create
and update
are successful, flow is redirected to show
action.We don't want to spoil your minds with our custom solution, but to get to know if there is a clear, Rails solution for that.
In our opinion, there is no such solution in Rails documentation, as we found out reading following sources:
API documentation doesn't get to many-to-many relation, which is the case in our app.
In advance, thanks for help!
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f61e6b1f-958f-4018-b73f-b5495ebef2a8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
We are working with nested attributes and we've reached a point where we're not sure if there is a better, clearer, "more rails" way of dealing with it.
We have 3 models - Organisation, Category and a strictly join table CategoryOrganisation (no additional attributes). The relation between Organisation and Category is many-to-many.
Now, we want to create a form with checkboxes through which the categories for organisations can be added and removed. The example form would look like that:
--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
To post to this group, send email to rubyonra...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/8b2c9630-8070-4ae8-8bf5-8749f77cb992%40googlegroups.com.