Home>
1

Current status,
If i enter the URL directly
Saved by another user
Because it will also transition to the edit page
I want to prevent transition

2Error message
NoMethodError in PrototypesController # show
Undefined method ʻuser_id'for nil: NilClass
3 Applicable source code

prototypes_controller.rb

class PrototypesController</pre>
<p><br />
routes.rb</p>
<pre><code>Rails.application.routes.draw do
  devise_for: users
  root to:'prototypes # index'
  resources: prototypes do
  resources: comments, only :: create
  end
end


4 What I researched and tried
I also tried the following code but couldn't solve it

def move_to_index
 unless user_signed_in?
  redirect_to action :: index
 end

5 Supplementary information such as the version of the tool i am using

  • Answer # 1

    edit@prototype = Prototype.find (params [: id])After the

    unless @ prototype.user_id == current_user.id
      Processing not to edit
    end