Allow linking content to universes

This commit is contained in:
Andrew Brown 2016-08-06 01:58:52 -05:00
parent 5044122b11
commit 0654b36ca1
2 changed files with 9 additions and 1 deletions

View File

@ -31,11 +31,15 @@
<div id="<%= category %>" class="row">
<% data[:attributes].each do |attribute| %>
<div class="col s10 m8 l4">
<%# TODO: not this lol %>
<% value = content.send(attribute) %>
<% if value.is_a?(ActiveRecord::Associations::CollectionProxy) %>
<% through_class = content.class.reflect_on_association(attribute).options[:through].to_s %>
<%= render 'content/form/relation_input', f: f, attribute: attribute, relation: through_class %>
<% elsif attribute == 'universe_id' %>
<div class="input-field">
<%= f.label attribute %><br />
<%= f.select attribute, current_user.universes.sort_by(&:name).map { |u| [u.name, u.id] }.compact, include_blank: true %>
</div>
<% else %>
<%= render 'content/form/text_input', f: f, attribute: attribute %>
<% end %>

View File

@ -36,6 +36,10 @@
<script type="text/javascript">
<%= yield :javascript %>
$(document).ready(function() {
$('select').material_select();
});
</script>
</body>