Sha256: 7862b0892b6eed86bc2a4be5f6c6af106d90c03313d06292cc5ddbdc335d9f35
Contents?: true
Size: 1.53 KB
Versions: 13
Compression:
Stored size: 1.53 KB
Contents
class OrganizationsController < ApplicationController include Applicat::Mvc::Controller::Resource before_filter :find_organization load_and_authorize_resource rescue_from ActiveRecord::RecordNotFound, with: :not_found respond_to :html, :js, :json def index @parent = find_parent Organization::PARENT_TYPES @organizations = @parent ? @parent.organizations.order(:name) : Organization.order(:name) respond_to do |format| format.html format.json { render json: @organizations.tokens(params[:q]) } end end def show end def new @organization = Organization.new end def create @organization = current_user.organizations.new(params[:organization]) if @organization.save redirect_to @organization, notice: t('general.form.successfully_created') else render :new end end def edit end def update if @organization.update_attributes(params[:organization]) redirect_to @organization, notice: t('general.form.successfully_updated') else render :edit end end def destroy @organization.destroy redirect_to organizations_url, notice: t('general.form.destroyed') end def resource @organization end private def not_found redirect_to organizations_path, notice: t('organizations.exceptions.not_found') end def find_organization @organization = Organization.friendly.find(params[:id]) if params[:id].present? end end
Version data entries
13 entries across 13 versions & 1 rubygems