Answer to Question #41982 in Ruby | Ruby on Rails for MagzhanKZ

Question #41982
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
0
Expert's answer

Answer in progress...

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS