는 아직도 레일에 새로운 오전 나는 내 레일 응용 프로그램에 대한 기본 탐색 역할을 section_links
다음과 같습니다현재 컨트롤러의 이름을 도우미 함수로 가져 오는 방법은 무엇입니까?
def section_link(title, section, path)
options = {}
options[:class] = 'current' if section == controller_name
link_to title, path, options
end
인가가 :
<%= section_link(Organisation.model_name.human(:count => 2), 'organisations', organisations_path) %>
<%= section_link(Person.model_name.human(:count => 2), 'people', people_path) %>
<%= section_link(Project.model_name.human(:count => 2), 'projects', projects_path) %>
<%= section_link(Invoice.model_name.human(:count => 2), 'invoices', invoices_path) %>
<%= section_link(Payment.model_name.human(:count => 2), 'payments', payments_path) %>
내가이 아주 기본적인 도우미 함수를 썼다을 어떤 방법이 도우미 함수를 건조, 그래서 나는 이런 식으로 뭔가가 링크하기 위해 말할 수있다 :
<%= section_link("Organisations") %>
몇 시간 동안이 작업을 시도했지만 현재 컨트롤러의 이름을 도우미 함수에 전달하는 방법을 모르겠습니다. 이 어떤 도움을
감사합니다 ...
정말 잘 작동합니다. 감사합니다! – Tintin81
@ Tintin81 그게 당신이 원했던 것이고 효과가 있다면 대답을 대답으로 표시하십시오. – Raed