Что случилось, ребята!
Я пытался реализовать ассоциацию has_and_belongs_to_many в моем приложении Rails (4). Вот мой код:
Моя категория модель
class Admin::Category
include Mongoid::Document
...
has_and_belongs_to_many :estimates, class_name: "User::Estimate", :inverse_of => :categories
end
Моя модель оценки
class User::Estimate
include Mongoid::Document
...
has_and_belongs_to_many :categories, class_name: "Admin::Category", :inverse_of => :estimates
end
Сильные параметры
def user_estimate_params
params.require(:user_estimate).permit({:category_ids => []}, :favorite_time, :city_id, :number_of_guests, :event_date, :stage_where_it_is, :event_type, :observation, user_attributes:[:name, :email, :receive_news, :password, :password_confirmation, :preferred_phone, :alternate_phone])
end
Мой запрос
Parameters: {"utf8"=>"✓", "authenticity_token"=>"JJk6m+5VV7tCLDeUCRkQatQOw/fFiw8LCV39casua+c=", "user_estimate"=>{"user_attributes"=>{"email"=>"user@email.com"}, "city_id"=>"523b638b5383de1887000001", "event_type"=>"Casamento", "number_of_guests"=>"456", "event_date"=>"21/11/2013", "stage_where_it_is"=>"Nos próximos 30 dias", "category_ids"=>["523b667687924d211527530e", "523b667b87924d2115275317"], "observation"=>""}, "event_type_select"=>"527ace4353455263c9000000", "commit.x"=>"149", "commit.y"=>"40"}
Unpermitted parameters: category_ids
Как видите, я получаю ошибку Непередные параметры: Category_IDS, что заставляет меня неспособно сохранить мои категории, даже то, что категории уже были добавлены в метод сильных параметров.
Я использую MongoDB/Mongoid.
Я нашел много подобных вопросов, но эти вопросы были решены, добавив => [
К методу сильных параметров, как я уже сделал.
Любая помощь?
ваше здоровье