Created
July 14, 2013 06:48
-
-
Save poc7667/5993437 to your computer and use it in GitHub Desktop.
Controller
This file contains 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 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