Advertisement
Guest User

Untitled

a guest
Dec 21st, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 KB | None | 0 0
  1. redirect_to post_path(@post)
  2.  
  3. class CommentsController < ApplicationController
  4.  
  5. before_action :authenticate_user!
  6.  
  7. def create
  8. @topic = Topic.find(params[:topic_id])
  9. @post = @topic.posts.find(params[:post_id])
  10.  
  11. @comment = Comment.new(comment_params)
  12. @comment.post = @post
  13.  
  14. redirect_to post_path(@post)
  15. end
  16.  
  17. private
  18.  
  19. def comment_params
  20. params.require(:comment).permit(:title, :body)
  21. end
  22. end
  23.  
  24. Rclone::Application.routes.draw do
  25. get "comments/create"
  26. devise_for :users
  27. resources :users, only: [:update]
  28.  
  29. resources :topics do
  30. resources :posts, except: [:index] do
  31. resources :comments, only: [:create]
  32. end
  33. end
  34.  
  35. get '/posts/:id/comments', to: 'posts#show'
  36.  
  37. get 'about' => 'welcome#about'
  38.  
  39. root to: 'welcome#index'
  40. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement