link_to
을 내부적으로 호출하는 song_link
메서드가 있습니다. 호출자가 옵션 해시를 song_link
에 전달하면 관련 옵션을 사용하고 나머지는 link_to
으로 전달합니다. 여기에 내 코드입니다 :선택적으로 다른 방법으로 옵션 전달
def song_link(song, separator = nil, options = {})
if separator.class == Hash
options = separator
separator = nil # not sure about this logic either!
# I guess I should roll it into the options hash
end
primary_only = false
if options[:primary_only]
options.delete(:primary_only)
primary_only = true
end
link_to title_with_artists(song, separator, primary_only), song_path(:song_slug => song.song_slug, :artist_slug => song.artist_slug), options
end
즉, 나는 options[:primary_only]
이 있는지 여부를 확인하려면, 그것은 분명히 link_to
이 방법을 따라 전달하지 않고 song_link
의 목적으로 사용 않는 경우는하지 않습니다 규모가 song_link
과 관련이 있지만 link_to
과 관련된 옵션을 더 추가하면됩니다. 어떻게해야합니까?
그래서 기본적으로 내가하고있는 일을합니까? –
두 가지 옵션 해시를 전달하거나 전달합니다. –