2017-06-04 53 views
0

所以我試圖添加此代碼首先視圖,然後控制器。它沒有工作,並給了我一個錯誤:未定義的方法保存爲4:Fixnum。Rails沒有索引位置

代碼:

<% unless location.user.interests.blank? %> 
    <% @merged_array = location.user.interests.split(',').uniq + 
         current_user.interests.split(',').uniq %> 
    <% location.score = @merged_array.length - @merged_array.uniq.length %> 
    <% location.score.save %> 
<% else %> 
    <% location.score = 0 %> 
    <% location.score.save %> 
<% end %> 

但後來我從兩個控制器和視圖.....現在索引頁面沒有顯示的位置在所有我檢查和顯示頁面是工作和記錄刪除它依然存在: INDEX.HTML.ERB:https://github.com/Hisaan-Anjum/friends/blob/master/app/views/locations/index.html.erb 控制器:https://github.com/Hisaan-Anjum/friends/blob/master/app/controllers/locations_controller.rb

+0

請在你的問題中添加代碼,而不是提供外部鏈接。 – Gerry

回答

1

這是真的它應該工作的方式。

PS:你不想成爲讓生產成爲新員工指南的人。 https://www.reddit.com/r/cscareerquestions/comments/6ez8ag/accidentally_destroyed_production_database_on/

除此之外,繼續前進!

0

對不起忘了它只顯示50英里半徑內的位置,我正在旅行......傻我:)