0
탭에서 내 작업을 표시하기 위해 도우미를 추가하고 싶습니다. 당신은 CONCAT을 혼합 값을 반환하는탭에 컬렉션을 표시하는 도우미 메서드를 작성하는 방법
concat content_tag :h3 do
item.name
end
content_tag :p do
item.description
end
:
module Users::TasksHelper
include ActionView::Helpers::UrlHelper
def present_in_tabs collection
content_tag :div, class: "tabbable tabs-left" do
content_tag :ul, class: 'nav nav-tabs' do
collection.collect do |item|
content_tag :li do
link_to "Zadanie #{1}", "#task-#{item.id}", data: { toggle: 'tab' }
end
end.join.html_safe
end
content_tag :div, class: 'tab-content' do
collection.collect do |item|
content_tag :div, class: 'tab-pane' do
concat content_tag :h3 do
item.name
end
content_tag :p do
item.description
end
end
end.join.html_safe
end
end
end
end
이 내가
.tabbable.tabs-left
%ul.nav.nav-tabs
- @related_tasks.each_with_index do |task, i|
%li{class: if task == @current_task then 'active' end}
= link_to "Zadanie #{i+1}", "#task-#{task.id}", data: { toggle: 'tab' }
.tab-content
- @related_tasks.each do |task|
.tab-pane{id: "task-#{task.id}", class: if task == @current_task then 'active' end}
%h3= task.name
%p
= task.description
이미 시도한 것을 보여줄 수 있습니까? – Donovan
왜이 방법을 도우미 메서드로 변환하고 부분은 사용하지 않으시겠습니까? – nickcen
부분적으로 그것을 간단하게 emplement 할 수 있습니다. – itsnikolay