해시에 키와 값을 명시 적으로 설정 한 다음 선택에 사용하려면 어떻게해야합니까? 외부 링크를 저장할 수있는 링크 모델이 있습니다. 링크에는 제목과 URL이 있습니다. 제목으로 키를 사용하고 url을 값으로 사용하고 싶습니다.선택에 대한 키와 값을 명시 적으로 설정
--------------------- 업데이트 ------------------------ -
이 작품 ..
links = Link.all
link_array = []
links.each do |link|
link_array << [link.title,link.url]
end
하지만, 지금 여기 히치입니다. 이 배열을 다른 배열에 결합하여 두 모델을 단일 양식 선택에서 선택할 수 있도록하고 싶습니다. 이처럼 ...
a = PagesController.action_methods
# this grabs each action from the pages controller that will later be used as a route
b = a.select {|s| s.include? "callback"}
c = a - b
# b and c removes any position in the array that includes the word 'callback' so that only actions defined in the controller are returned
links = Link.all
link_array = []
links.each do |link|
link_array << [link.title,link.url]
end
@all_links = c + link_array
# desired result is an array used in a single form select containing both external links and internal links