Can you help me with implementation CarrierWave in Rails
I had an error it says that NoMethodError in HomeworksController
and here my HomeworksController class:
class HomeworksController < ApplicationController
before_action :signed_in_user, only: [:create, :destroy]
before_action :correct_user, only: :destroy
def create
@homework = current_user.homeworks.build(homework_params)
if @homework.save
flash[:success] = "Homework created!"
redirect_to root_url
else
@feed_items = []
render 'static_pages/home'
end
end
def new
@homework =Homework.new
end
def destroy
@homework.destroy
redirect_to root_url
end
def index
@homeworks=Homework.all
end
private
def homework_params
params.require(:homework).permit(:content, :attachment)
end
def correct_user
@homework = current_user.homeworks.find_by(id: params[:id])
redirect_to root_url if @homework.nil?
end
end
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment