Skip to content

Instantly share code, notes, and snippets.

@LBRapid
Created August 2, 2010 21:23
Show Gist options
  • Select an option

  • Save LBRapid/505339 to your computer and use it in GitHub Desktop.

Select an option

Save LBRapid/505339 to your computer and use it in GitHub Desktop.
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