class GroupsController

Public Instance Methods

create() click to toggle source

Create new group for current user.

# File app/controllers/groups_controller.rb, line 13
def create
  @group = current_user.owned_groups.new(group_params)
  respond_to do |format|
    if @group.save
      format.js {render 'save'}
    else
      message = "Group was not Created."
      format.js { redirect_via_turbolinks_to new_group_path, notice: message}
    end
  end
end
destroy() click to toggle source

Find and delete the group.

# File app/controllers/groups_controller.rb, line 45
def destroy
  Group.find(params[:id]).destroy
  respond_to do |format|
    format.js
  end
end
edit() click to toggle source

Find the group for editing.

# File app/controllers/groups_controller.rb, line 26
def edit
  @group = current_user.owned_groups.find(params[:id])
  render layout: false
end
events() click to toggle source

Fetch all events between start date and end date.

# File app/controllers/groups_controller.rb, line 53
def events
  @start_date = Date.parse(params[:start])
  @end_date = Date.parse(params[:end])
  @events = @group.events.for_date_range(@start_date, @end_date)
  respond_to do |format|
    format.json
  end
end
new() click to toggle source

Intialize new object to create group.

# File app/controllers/groups_controller.rb, line 7
def new
  @group = Group.new
  render layout: !request.xhr?
end
show() click to toggle source

Find the group.

# File app/controllers/groups_controller.rb, line 63
def show
  @group = current_user.groups.find(params[:id])
  respond_to do |format|
    format.json { render :partial => 'chat/chat_members', :locals => {:group => @group}}
  end
end
update() click to toggle source

Find and update the group.

# File app/controllers/groups_controller.rb, line 32
def update
  @group = current_user.owned_groups.find(params[:id])
  respond_to do |format|
    if @group.update_attributes(group_params)
      format.js {render 'save'}
    else
      message = "Group was not updated."
      format.js { redirect_via_turbolinks_to new_group_path, notice: message}
    end
  end
end