categorization
을 나타내는 아이콘을 사용자가 클릭하면 홈 페이지에 challenges
과 동일한 categorization
만 표시하는 방법은 무엇입니까?동일한 속성을 가진 동일한 페이지에 객체를 나열하는 방법은 무엇입니까?
<%= link_to categorization_path(categorization: :adventure) do %>
<span class="glyphicon glyphicon-picture", id="challenge-category"></span>
<% end %>
<%= link_to categorization_path(categorization: :health) do %>
<span class="glyphicon glyphicon-heart", id="challenge-category"></span>
<% end %>
<%= link_to categorization_path(categorization: :work) do %>
<span class="glyphicon glyphicon-briefcase", id="challenge-category"></span>
<% end %>
<%= link_to categorization_path(categorization: :buy) do %>
<span class="glyphicon glyphicon-shopping-cart", id="challenge-category"></span>
<% end %>
<%= link_to categorization_path(categorization: :wacky) do %>
<span class="glyphicon glyphicon-wine-glass", id="challenge-category"></span>
<% end %>
보면 다음 link_to
상기 사용자가 클릭하는 각 categorization
함께해야하는 유일한 목록 도전.
routes.rb
get ":categorization", to: "pages#home", as: 'categorization'
pages_controller.rb
def home
@challenges = current_user.challenges.send(params[:categorization]).order("deadline ASC")
end
challenge.rb
CATEGORIZATION = ['adventure', 'health', 'work', 'buy', 'wacky']
scope :adventure, -> { where(categorizations: 'Adventure') }
scope :health, -> { where(categorizations: 'Health') }
scope :work, -> { where(categorizations: 'Work') }
scope :buy, -> { where(categorizations: 'Buy') }
scope :wacky, -> { where(categorizations: 'Wacky') }
어떤 오류가 발생합니까? – potashin
'TypeError (nil은 기호가 아닙니다.) : 컨트롤러의 행에 대해 @potashin –