# File app/controllers/comments_controller.rb, line 18 def create # Lets make the comment_type = 1 if for league, 2 if for user, 3 if for company @comment = Comment.new(params[:comment]) @comment.posted_at = DateTime.now @comment.user_id = current_user.id flash[:focus] = true respond_to do |format| if @comment.save if @comment.comment_type == 1 format.html { redirect_to league_url(@comment.location_id), notice: 'Comment was successfully posted' } elsif @comment.comment_type == 2 format.html { redirect_to user_url(@comment.location_id), notice: 'Comment was successfully posted' } elsif @comment.commene_type == 3 format.html { redirect_to league_url(@comment.location_id), notice: 'Comment was successfully posted' } end else format.html { render action: "new" } end end end
# File app/controllers/comments_controller.rb, line 55 def destroy @comment = Comment.find(params[:id]) @comment.destroy end
# File app/controllers/comments_controller.rb, line 14 def edit @comment = Comment.find(params[:id]) end
# File app/controllers/comments_controller.rb, line 2 def index @comments = Comment.all end
# File app/controllers/comments_controller.rb, line 10 def new @comment = Comment.new end
# File app/controllers/comments_controller.rb, line 6 def show @comment = Comment.find(params[:id]) end
# File app/controllers/comments_controller.rb, line 43 def update @comment = Comment.find(params[:id]) respond_to do |format| if @comment.update_attributes(params[:comment]) format.html { redirect_to @comment, notice: 'Comment was successfully updated.' } else format.html { render action: "edit" } end end end