Answer the question
In order to leave comments, you need to log in
What is the error when creating links (belongs_to) in ActiveAdmin?
There are two models - Blog and Post.
blog.rb:
class Blog < ActiveRecord::Base
has_many :post
end
class Post < ActiveRecord::Base
belongs_to :blog
end
ActiveAdmin.register Blog do
permit_params do
allowed = [
:title,
:description
]
permitted = *allowed
permitted << :other if params[:action] == 'create' && current_user.is_admin?
permitted
end
end
ActiveAdmin.register Post do
belongs_to :blog
end
Answer the question
In order to leave comments, you need to log in
The name of the other model is plural when declaring a has_many relationship.has_many posts
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question