4

在 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"
4

1 回答 1

2

试试这个:

render :partial => "show", :locals => {:article => article }

于 2012-08-09T04:01:40.713 回答