Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class TextbooksController < ApplicationController
- before_action :signed_in_user
- def create
- @textbook = current_user.textbooks.build(textbook_params)
- if @textbook.save
- flash[:success] = "Textbook added!"
- redirect_to root_url
- else
- render 'static_pages/home'
- end
- end
- def destroy
- end
- private
- def textbook_params
- params.require(:textbook).permit(:content)
- end
- def correct_user
- @textbook = current_user.textbooks.find_by(id: params[:id])
- redirect_to root_url if @textbook.nil?
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement