40 lines
1.3 KiB
Ruby
40 lines
1.3 KiB
Ruby
class OrgSubfieldsController < ApplicationController
|
|
def create
|
|
@subfield = OrgSubfield.create(:name => params[:name])
|
|
@organization = Organization.find(params[:organization_id])
|
|
@organization.org_subfields << @subfield
|
|
@subfield.update_attributes(:priority => @subfield.id, :field_type => params[:field_type])
|
|
end
|
|
|
|
def show
|
|
@organization = Organization.find(params[:id])
|
|
@subfield = @organization.org_subfields.first
|
|
if @subfield.field_type == 'Post'
|
|
redirect_to organization_path(@organization, :org_subfield_id => @subfield.id)
|
|
else
|
|
|
|
end
|
|
# @org_subfield = OrgSubfield.find(params[:id])
|
|
# @organization = @org_subfield.organization.id
|
|
# @messages = []
|
|
# @messages << @org_subfield.org_document_comments
|
|
# @messages << @org_subfield.messages
|
|
# @messages.sort{|a, b| b.updated_at <=> a.updated_at}
|
|
# respond_to do |format|
|
|
# format.html{render :layout => 'base_org'}
|
|
# end
|
|
end
|
|
def destroy
|
|
@subfield = OrgSubfield.find(params[:id])
|
|
@organization = Organization.find(@subfield.organization_id)
|
|
@subfield.destroy
|
|
end
|
|
|
|
def update
|
|
@subfield = OrgSubfield.find(params[:id])
|
|
@organization = Organization.find(@subfield.organization_id)
|
|
@subfield.update_attributes(:name => params[:name])
|
|
end
|
|
|
|
end
|