- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
错误:
You have a nil object when you didn't expect it!
You might have expected an instance of Array.
The error occurred while evaluating nil.[]
app/controllers/users_controller.rb:45:in `update'
Controller users_controller
def update
@user.groups = Group.find(@params[:group_ids]) if @params[:group_ids]
if @user.update_attributes(params[:user])
flash[:success] = "User updated."
#Redirect back to current users, i've change this as after the admin edit a user it would redirect them
#Too that users account which conflicts.
#if current_user.admin? # If the current user is an admin move them back to the user list page.
#redirect_to users_path
#else # if its a normal user just redirect them back to there dashboard
redirect_to @user
#end
else
@title = "Edit user"
render 'edit'
end
end
View (edit.html.erb):
<% for group in @groups %>
<%= check_box_tag "user[group_ids][]", group.id %>
<%= group.description %>
<% end %>
最佳答案
@user.groups = Group.find(@params[:group_ids]) if @params[:group_ids]
@user.groups = Group.find(params[:group_ids]) if params[:group_ids]
关于ruby-on-rails - UsersController 中的 NoMethodError#update,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6583151/
在 Rails 控制台中,我得到以下信息: >> UsersController LoadError: Expected /../app/controllers/admin/users_control
几周前我开始在 Rails 中编码,但我不明白为什么会出现这个错误。我使用 Devise 进行登录,使用 Formtastic 进行表单登录。该应用程序一直正常工作,直到我添加了 Acts_like_
我一直在关注 cakephp.org 上的博客教程,我添加和编辑帖子表工作正常。我想添加用户登录名,但在按照教程进行操作时遇到问题。当我现在运行我的应用程序时,我不断收到错误消息: 错误:找不到 Us
我在访问 /users/new 时遇到错误在 Rails 4 中为 Unable to autoload constant UsersController, expecting /app/contro
我之前可能问过与此相关的问题,但对答案不满意,没有答案有效.....我的怀疑有点不同,我有两个 Controller 1.用户 Controller 。2.成员 Controller 。 我怀疑 Au
我希望用户注册该应用程序,但我在下面看到此错误, ActionController::ParameterMissing in UsersController#show param is missing
错误: You have a nil object when you didn't expect it! You might have expected an instance of Array. T
提交表单后出现此错误。 # 的未定义方法 `user_url' 我没有在我的路由文件中使用 resources :users,我想这就是我收到错误的原因。 我的routes.rb TaskManage
我一直在开发 API,但是当我访问端点时 无法自动加载常量 Api::V1::UsersController,预期为/Users/toshikiinami/Desktop/billing/app/co
对于个人项目,我想在Rails 4中创建一个Restful Web服务。 因此,我使用rails-api创建了我的第一个项目,并添加以下代码: MyProject> config目录中的routes.
在获得学位后,我目前正在自学 ruby on rails。我真的是这门语言的新手,想更多地了解迁移的工作原理。 Error Of problem 我已经通过迁移更新了我现有的用户表,以允许添加一个
我刚刚尝试重命名我的 Controller 和所有与之关联的文件。 但是,我收到了这个错误: NameError in UsersController#show uninitialized const
我将使用 Ruby on Rails 创建 restful API。我想创建、删除、显示和更新数据。所有这些都必须是 JSON 才能在 Android 设备中获取。我还使用 Postman 检查我的
在我使用 Rails 4.1.0 和 Ruby 2.1.0 的 Rails 应用中, 我一直在使用 Authlogic 对用户进行身份验证。 在 users_controller.rb 中,我有一个创
设计生成了以下代码以将用户注销: 并且在执行rake routes时出现路由 destroy_user_session DELETE /users/sign_out(.:format) {:
所以我有这个应用程序使用 omniauth-facebook 来验证用户,一个新用户在 session Controller 中创建: class SessionsController , 但我收到
在 ActiveAdmin 中,当我想删除用户时出现以下错误: ActiveRecord::InvalidForeignKey in Admin::UsersController#destroy PG
我应该实现new、create、edit、update和destroy > 对应模型使用 Devise 的 :registerable 模块的 Controller 上的操作? 换句话说,即使 Dev
这可能真的很基础,但我似乎无法理解。 基本上,当我尝试使用表单创建新用户时,用户详细信息已经存在且不是唯一的,我收到以下错误: ArgumentError in UsersController#cre
我无法再将数据保存到我的数据库并得到 Errno::ECONNREFUSED in UsersController#create和 Connection refused - connect(2) .这
我是一名优秀的程序员,十分优秀!