1

I got two models; film model is the parent and the review model is the child. I expect the following code to direct me back to the film interface:

 def create
    @film = Film.find(params[:film_id])
    @review = @film.reviews.new(review_params)
    if @review.save
    redirect_to film_path(@film)
    else
        render "films/#{@film.id}"
     end 
   end

It renders me back to the following address: films/22/reviews when it suppose to direct me back to the same interface (films/22)?

I want to return back to the same interface so i can post the errors the user has made?

javacoder
  • 17
  • 6

1 Answers1

1

Try it in else part

flash[:alert] = @review.errors.full_messages.join(',  ') 
redirect_to :back
Vishal G
  • 1,521
  • 11
  • 30
  • Cheers mate, one more question; how would i change the lettering and layout of the error? – javacoder Nov 25 '16 at 19:15
  • @javacoder use this http://stackoverflow.com/questions/808547/fully-custom-validation-error-message-with-rails................. Accept answer as solution by clicking tick mark and upvote if you think your problem is solved – Vishal G Nov 25 '16 at 19:19