A
A
Anton2016-04-27 03:08:28
Ruby on Rails
Anton, 2016-04-27 03:08:28

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

post.rb:
class Post < ActiveRecord::Base
  belongs_to :blog
end

Further ActiveAdmin files:
admin/blog.rb:
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

admin/post.rb:
ActiveAdmin.register Post do
  belongs_to :blog
end

I did everything according to this manual: activeadmin.info/docs/2-resource-customization.htm...
As a result, I get an error:
bd92b70f6ed741ceb871ca59987bf5d4.png
I googled everything I could. There is nothing anywhere.
I can add blog entries. The problem is only with links - on the page: /admin/blogs/5/posts .
What is the problem? I didn't do anything out of the ordinary. Everything is pattern.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
N. Bekseitov, 2016-04-27
@hummingbird

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 question

Ask a Question

731 491 924 answers to any question