Я получаю следующую ошибку, когда я пытаюсь отправить в мою форму _follow.html.rb и не могу понять, почему параметры не передаются.Как решить ошибку ParameterMissing?
я получил:
ActionController :: ParameterMissing в UsersController # обновлении
пары отсутствуют или значение пусто: Пользователь
def user_params
params.require(:user).permit(:name, :email, :password,
:password_confirmation, :followed_user)
end
Это является просьбой
Parameters:
{"utf8"=>"✓",
"_method"=>"patch",
"authenticity_token"=>"LOnA6CA3yQYaCDqme6OkxPZlkBRvybhYANreU3BxuV8=",
"followed_user"=>"#<User:0x007f4e902fcf20>",
"commit"=>"Follow",
"id"=>"57f2b32b717f01297dda1759"}
Пыльник - вид
<%= form_for(current_user) do |f| %>
<div><%= hidden_field_tag :followed_user, @user %></div>
<%= f.submit "Follow", class: "btn btn-primary" %>
<% end %>
И это моя модель пользователя
class User
include Mongoid::Document
include ActiveModel::SecurePassword
has_many :microposts, dependent: :destroy
has_and_belongs_to_many :followers, :class_name => 'User', :inverse_of => :following
has_and_belongs_to_many :following, :class_name => 'User', :inverse_of => :followers
field :name, type: String
field :email, type: String
field :password_digest, :type => String
field :admin, type: Boolean, default: false
field :created_at, type: Date, default: Time.current
has_secure_password
def feed
microposts
end
# Follows a user.
def follow(other_user)
following << other_user
end
# Unfollows a user.
def unfollow(other_user)
following.delete(other_user)
end
# Returns true if the current user is following the other user.
def is_following?(other_user)
following.include?(other_user)
end
end