Created
October 24, 2013 19:52
-
-
Save jcutrell/7143854 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
class ClassRegistrationsController < InheritedResources::Base | |
before_filter :authenticate_user! | |
def permitted_params | |
params.permit(:class_registration => [ | |
:person_id, :classdate_id, | |
:document_assignments_attributes => [ | |
:uploaded_document_id, | |
:uploaded_document => [ | |
:document, :owner_type, :owner_id | |
] | |
] | |
]) | |
end | |
end |
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
class DocumentAssignment < ActiveRecord::Base | |
belongs_to :uploaded_document | |
accepts_nested_attributes_for :uploaded_document | |
belongs_to :documentable, polymorphic: true | |
end |
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
<p id="notice"><%= notice %></p> | |
<p> | |
<strong>Course:</strong> | |
<%= @class_registration.classdate.course.name %> | |
</p> | |
<p> | |
<strong>Person:</strong> | |
<%= @class_registration.person.full_name %> | |
</p> | |
<p> | |
<strong>Status:</strong> | |
<%= @class_registration.registration_status.join("<br>").html_safe %> | |
</p> | |
<%= form_for @class_registration do |f| %> | |
<%= f.fields_for :document_assignments, @class_registration.document_assignments.build do |ff| %> | |
<% @class_registration.missing_documents.each do |doc| %> | |
<%= ff.label doc.name %> | |
<%= ff.collection_select(:uploaded_document_id, @class_registration.person.uploaded_documents, :id, :name) %> | |
<%= ff.fields_for @class_registration.uploaded_documents.build do |fff| %> | |
Upload a new form: <%= fff.file_field :document %> | |
<%= fff.hidden_field :owner_id, :value => @class_registration.person.id %> | |
<%= fff.hidden_field :owner_type, :value => "Person" %> | |
<% end %> | |
<% end %> | |
<% end %> | |
<%= f.submit %> | |
<% end %> | |
<%= link_to 'Edit', edit_class_registration_path(@class_registration) %> | | |
<%= link_to 'Back', class_registrations_path %> |
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
class UploadedDocument < ActiveRecord::Base | |
has_many :document_assignments | |
belongs_to :owner, polymorphic: true | |
has_attached_file :document | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment