Created
August 2, 2010 21:23
-
-
Save LBRapid/505339 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| returning(String.new) do |html| | |
| @resource[:class].typus_defaults_for(:relationships).each do |relationship| | |
| association = @resource[:class].reflect_on_association(relationship.to_sym) | |
| next if @current_user.cannot?('read', association.class_name.constantize) | |
| macro = association.through_reflection ? :has_and_belongs_to_many : association.macro | |
| case macro | |
| when :has_and_belongs_to_many | |
| html << typus_form_has_and_belongs_to_many(relationship) | |
| when :has_many | |
| if association.options[:through] | |
| # Here we will shot the relationship. Better this than raising an error. | |
| else | |
| html << typus_form_has_many(relationship) | |
| end | |
| when :has_one | |
| html << typus_form_has_one(relationship) | |
| end | |
| end | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment