0
基本上,我希望用户能够从5个不同的下拉菜单,稍后将在用户的显示页面上查看选择他们的前5名技能环路选择下拉菜单5倍
用户控制器:
class UsersController < ApplicationController
def new
@user = User.new
end
def show
@user = User.find(params[:id])
@events = @user.events
end
def create
@user = User.new(user_params)
if @user.save
session[:user_id] = @user.id
redirect_to root_url
else
render "new"
end
end
def edit
@user = current_user
end
def update
@user = current_user
@user.update_attributes(user_params)
if @user.save
redirect_to user_path(current_user)
else
render "edit"
end
end
def upload
uploaded_io = params[:user][:picture]
File.open(Rails.root.join('public', 'uploads', uploaded_io.original_filename), 'wb') do |file|
file.write(uploaded_io.read)
end
end
private
def user_params
params.require(:user).permit(:email, :password, :password_confirmation, :first_name, :last_name, :region, :volunteer_position, :summary, :date_of_birth, :picture, :hours, :org_admin, :skills, :goals)
end
end
users model:
SKILLS = ["","Administrative", "Analytical", "Artistic/Creative", "Budgeting",
"Communicaton", "Computer", "Conflict Resolution", "Creating Ideas",
"Creating Procedures", "Creating New Solutions", "Customer Service",
"Decision Making", "Fundraising", "Handling Complaints", "Innovative",
"Leadership", "Learning", "Logical Thinking", "Maintaining High Levels of Activity",
"Negotiating", "Networking", "Organizational", "Planning", "Problem Solving",
"Reporting", "Team Work", "Technical", "Time Management", "Training"]
def select_skills
@skills = []
5.times do |i|
return i.skills
end
end
用户show.html.erb
<tr>
<td>skills:</td>
<td><%= current_user.skills %></td>
</tr>
edit.html.erb
<tr>
<td> User Goals </td>
<% select User::SKILLS.each do |skill|%>
<% @skill = Skills.order.first(5) %>
<tr>
<th><%= current_user.skills %></th>
</tr>
<% end %>
错误消息:在用户#编辑
引发ArgumentError
错误的参数数目(1给出,预期2..5)
您能够发布完整的错误消息,并且还你的模型,视图和控制器和应用程序目录结构中的每个文件的位置?我可能是错的,但我会期待你写的方法在控制器 – 2017-03-17 17:08:16
@RailsKiddie更新它! – Amena