не может получить доступ к проекту, созданному current_user.
project_controller.rb
def index
@projects = current_user.projects.all
end
def create
@project = current_user.projects.build(project_params)
respond_to do |format|
if @project.save
#ProjectMailer.activity_status(@project).deliver
format.html { redirect_to projects_url, notice: 'Project was successfully created.' }
format.json { render :show, status: :created, location: @project }
else
format.html { render :new }
format.json { render json: @project.errors, status: :unprocessable_entity }
end
end
end
index. html .erb
<% @projects.each do |project| %>
<tr>
<td><%= project.project_name %></td>
<tr>
<% end %>
user
has_many project
и project
has_many user
.
project.rb
has_many :users, through: :project_users
user.rb
has_many :project_users
project_user.rb
belongs_to :user
belongs_to :project
связано с этим сообщением - проблема в ассоциации has_and_belongs_to_many в рельсах