2010-01-04 7 views

답변

5

에 어쩌면, 도우미를 만들어야합니다 생각합니다. url_forActiveRecord 인스턴스가 전달되면 map.resources 설치로 가정합니다.

당신은 오히려이 작업을 수행해야합니다

# routes.rb 
map.post ":id", :controller => "posts", :action => "show" 

# named route 
post_path(@post) 

# full link_to 
link_to @post.title, post_path(@post) 
0

url_for을 사용하는 경우 /posts/ 섹션을 생략 할 수 없습니다. 난 당신이 루트로 url_for(@post)의 동작을 변경할 수 없습니다 application_helper.rb

def post_url(post) 
    "/#{post.id}" 
end 
관련 문제