Skip to content

Instantly share code, notes, and snippets.

@poc7667
Created July 14, 2013 06:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save poc7667/5993437 to your computer and use it in GitHub Desktop.
Save poc7667/5993437 to your computer and use it in GitHub Desktop.
Controller
class GroupsController < ApplicationController
def index
@groups = Group.all
end
def show
@group = Group.find(params[:id])
#@posts = @group.posts
end
def new
@group = Group.new
end
def edit
@group = Group.find(params[:id])
end
def update
@group = Group.find(params[:id])
if @group.update(group_params)
redirect_to group_path(@group)
else
render :edit
end
end
def create
@group = Group.new(group_params)
if @group.save
#flash[:notice] = group_params
redirect_to groups_path
else
#flash[:notice] = "failed"
render :new
end
#redirect_to groups_path
end
def destroy
@group = Group.find(pa)
end
def destroy
@group = Group.find(params[:id])
@group.destroy
redirect_to groups_path
end
private
def group_params
params.require(:group).permit(:title, :description)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment