0
저는 프론트 엔드 작업을 할 의무가 있었지만 쉽게 ERB를 파악할 수 있다고 생각했습니다. 내 app.rb 변수에루비 ERB를 사용하여 객체에서 반복하기
내가
이이
<% @listings.each do |value | %>
<strong><%= value %><br/>
<%# This returns {:name=>"blah", :location=>"New York"} %>
<strong><%= value['name']%></strong><br/>
<%# This returns nothing %>
<% end %>
어떻게 내가 이름 값을받을 수 있나요 index.erb 반복하려고 내 ERB 파일에서
def find_listings
3.times.map { random_item }
end
def random_item
{
name: 'blah',
location: 'LA'
}
end
get '/' do
@listings = find_listings
erb :index
end
을 정의?
나는 이것을 시도했지만 정의되지 않았다. [] method – artSir
@artSir 이것은 바뀌어야한다. – Abdullah
당신이 쓴다, 그것은 일했다. 그래서 wierd. 나는 그것을 시도했다. – artSir