当我试图导入.csv文件时,我会得到以下错误消息。
NoMethodError在Users1#index中用于#的未定义方法“`project”
我的users1_controller.rb
class Users1Controller < ApplicationController
def index
@users1 = User.all
end
def import
User.import(params[:file])
redirect_to root_url, notice: "Activity Data imported!"
end
end我的index.html.erb
<h1>Users1#index</h1>
<p>Find me in app/views/users1/index.html.erb</p>
<%= flash[:notice] %>
<table>
<thead>
<tr>
<th>Projects</th>
<th>Task ID</th>
<th>Tasks</th>
</tr>
</thead>
<tbody>
<% @users1.each do |user| %>
<tr>
<td><%= user.project %></td>
<td><%= user.task_id %></td>
<td><%= user.task %></td>
</tr>
<% end %>
</tbody>
</table>
<div>
<h4>Import that data!</h4>
<%= form_tag import_users_path, multipart: true do %>
<%= file_field_tag :file %>
<%= submit_tag "Import CSV" %>
<% end %>
</div> 发布于 2017-02-17 13:44:06
首先,我会问您是否正在为用户和AnonymousUser使用单个表。匿名用户是否响应:project?
https://stackoverflow.com/questions/42295452
复制相似问题