Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- redirect_to post_path(@post)
- class CommentsController < ApplicationController
- before_action :authenticate_user!
- def create
- @topic = Topic.find(params[:topic_id])
- @post = @topic.posts.find(params[:post_id])
- @comment = Comment.new(comment_params)
- @comment.post = @post
- redirect_to post_path(@post)
- end
- private
- def comment_params
- params.require(:comment).permit(:title, :body)
- end
- end
- Rclone::Application.routes.draw do
- get "comments/create"
- devise_for :users
- resources :users, only: [:update]
- resources :topics do
- resources :posts, except: [:index] do
- resources :comments, only: [:create]
- end
- end
- get '/posts/:id/comments', to: 'posts#show'
- get 'about' => 'welcome#about'
- root to: 'welcome#index'
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement