2012-08-06 54 views
4

在ActiveAdmin 0.4.3,和Rails 3.2.2我想定製我的文章模式顯示屏幕模型ActiveAdmin顯示部分沒有看到

ActiveAdmin.register Article do 

    show do 
    render "show" 
    end 

end 

而且在應用程序/視圖/管理/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" 

回答

2

試試這個:

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

+0

謝謝!有用! – Augusto 2012-08-09 07:34:45

+0

耶!這個問題源於部分不能訪問「文章」。你也可以使用這種技術來傳遞其他局部變量,但不要爲此而瘋狂。 – 2012-08-09 07:38:05