0
我有一部分被一對控制器重複使用。Rails:使用本地人時保持局部乾燥
現在我有這部分設置接受2我不想做的對象。
-if @article
.main-inner
.article-header
.article-title
[email protected]
-if [email protected]?
%span#byline
[email protected]
%span#timestamp
[email protected]_date.strftime("%a, %b %d, %Y %I:%M %Z")
.article-content
=truncate(@article.content, :length => 600).html_safe
-else
.main-inner
.article-header
.article-title
=article.title
-if !article.byline.blank?
%span#byline
=article.byline
%span#timestamp
=article.publish_date.strftime("%a, %b %d, %Y %I:%M %Z")
.article-content
=truncate(article.content, :length => 600).html_safe
當@article
def show
@article = Article.find_by_permalink(params[:permalink])
end
當通過當地人
$("#article").html("<%= escape_javascript render(:partial => 'article/view', :locals => { :article => @newarticle }) %>")
1)我如何鞏固我的部分,如果@article不使用。
2)在我的js。什麼是渲染偏好的正確語法,所以我不必說:partial =>'article/view'並使用:locals?
好了,現在我明白和意識到我不得不這樣做。謝謝! – user647345 2011-05-11 07:18:58