# File app/controllers/teams_controller.rb, line 36 def confirm_destroy authorize! :destroy, @team end
# File app/controllers/teams_controller.rb, line 14 def create @team = Team.new(params[:team]) authorize! :create, @team if @team.save redirect_to teams_path, :notice => team_flash(@team).html_safe else render :new end end
# File app/controllers/teams_controller.rb, line 40 def destroy authorize! :destroy, @team @team.destroy redirect_to(teams_path, :notice => "Awesome. You deleted #{@team.name}") end
# File app/controllers/teams_controller.rb, line 24 def edit end
# File app/controllers/teams_controller.rb, line 5 def index @teams = Team.paginate :page => params[:page] end
# File app/controllers/teams_controller.rb, line 9 def new @team = Team.new authorize! :create, @team end
# File app/controllers/teams_controller.rb, line 46 def search query = params[:term] @teams = Team.where("name ILIKE ?", "%#{query}%") respond_to do |format| format.html format.json { render :json => @teams.map{ |team| { :name => team.name, :id => team.id } } } end end
# File app/controllers/teams_controller.rb, line 27 def update authorize! :update, @team if @team.update_attributes(params[:team]) redirect_to teams_path, :notice => team_flash(@team).html_safe else render :edit end end