ruby-on-rails – ActiveAdmin show partial看不到模型

在ActiveAdmin 0.4.3和Rails 3.2.2中,我正在尝试自定义文章模式的显示屏幕

ActiveAdmin.register Article do

  show do
     render "show"
  end

end 

在app / views / admin / articles / _show.html.haml中

%div= article.description

但每当我试图展示我得到的文章时:

NoMethodError in Admin/articles#show

Showing /Users/phishman/Sites/wisegrowth/app/views/admin/articles/_show.html.haml where line #1 raised:

undefined method `description' for <article></article>
:Arbre::HTML::Article

Extracted source (around line #1):

1: %div= article.description

Trace of template inclusion: /Users/phishman/.rvm/gems/ruby-1.9.2-p290/gems/activeadmin-0.4.3/app/views/active_admin/resource/show.html.arb

Rails.root: /Users/phishman/Sites/wisegrowth
Application Trace | Framework Trace | Full Trace

app/views/admin/articles/_show.html.haml:1:in `_app_views_admin_articles__show_html_haml___3305533421865107600_2209712640'
app/admin/articles.rb:20:in `block (2 levels) in <top (required)>'
app/middleware/flash_session_cookie_middleware.rb:17:in `call'

你能帮帮我吗?这让我发疯了!

在控制台中,一切似乎工作正常,如果我这样做:

a = Article.last
a.description
=> "my article description"

最佳答案 试试这个:

渲染:部分=> “show”,:locals => {:article =>文章}

点赞