【问题标题】:rails ActiveAdmin belongs_to admin_inicio_bannerhomes_path()rails ActiveAdmin belongs_to admin_inicio_bannerhomes_path()
【发布时间】:2013-08-16 04:31:40
【问题描述】:

我有这个

class Inicio < ActiveRecord::Base
     has_many :bannerhomes
end
class Bannerhome < ActiveRecord::Base
  belongs_to :inicio
end

并且在 activeAdmin 中有这个

ActiveAdmin.register Inicio do
    sidebar "Project Details" do
      ul do
        li link_to("Bannerhome", admin_inicio_bannerhomes_path(Inicio))
          #it dont work with Inicio and inicio, why dont work?
        #li link_to("Bannerhome", admin_inicio_bannerhomes_path(1))
          #when i pass 1 it works, but i want every Bannerinicio that belongs to Inicio with id=1
      end
    end
end

ActiveAdmin.register Bannerhome do
    belongs_to :inicio    
end

我有一个 id=1 的 Inicio,和 4 个 id=1,2,3 和 4 的 Bannerhome,每个都有 inicio_id=1

我关注这个文档 http://www.activeadmin.info/docs/2-resource-customization.html#belongs_to

谢谢。

【问题讨论】:

    标签: ruby-on-rails-3 activeadmin belongs-to


    【解决方案1】:

    我有同样的问题,文件似乎缺少一些东西。添加:only =&gt; :show,所以侧边栏只在show action中出现,其中inicio可用

    sidebar "Project Details", :only => :show do
      ul do
        li link_to("Bannerhome", admin_inicio_bannerhomes_path(inicio))
      end
    end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-20
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多