Skip to content

Instantly share code, notes, and snippets.

@LeoAdamek
Created October 19, 2013 17:30
Show Gist options
  • Select an option

  • Save LeoAdamek/7058861 to your computer and use it in GitHub Desktop.

Select an option

Save LeoAdamek/7058861 to your computer and use it in GitHub Desktop.
class OrganizationsController < ApplicationController
before_filter :authenticate_user! , except: [:index , :show]
def index
@organizations = Organization.all
end
def show
@organization = Organization.friendly.find(params[:id])
end
def new
@organization = Organization.new if not @organization.is_a?(Organization)
end
def create
# Do some stuff to the params[:organization][:tags]
params[:organization][:tags] = params[:organization][:tags].gsub("+"," ").split(",")
@organization = Organization.new
@organization.update_attributes! organization_params
@organization.user = current_user
if @organization.save then
redirect_to @organization
end
end
def edit
end
def destroy
end
private
def organization_params
params.required(:organization).permit( :name , :tags , :description )
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment