ref: master
plugins/teams/controllers/myprofile/teams_plugin/teams_controller.rb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 |
class TeamsPlugin::TeamsController < MyProfileController before_filter :load_context def index render :index, locals: {context: @context} end def create @team = @context.teams.create! context: @context render json: @team end def update @team = @context.teams.find params[:id] attrs = params[:team].except :id, :members @team.update! attrs render nothing: true end def destroy @team = @context.teams.find params[:id] @team.destroy render nothing: true end protected def load_context @context = params[:context][:type].constantize.find params[:context][:id] end end |