Я новичок в рубин на рельсах, поэтому, пожалуйста, помогите мне :) Это моя ошибканеопределенный метод `find_by»
NoMethodError in Welcome#sucess
Showing ..app/views/welcome/sucess.html.erb where line #8 raised:
undefined method `find_by' for #<ActiveRecord::Relation:0x41dca80>
Extracted source (around line #8):
5: <%= @user.pass%><br />
6: <% if current_user && current_user != @user %>
7: <% if current_user.following.include?(@user) %>
8: <%= form_for(current_user.following_relations.find_by(following_id: @user.id),
9: html: { method: :delete }) do |f| %>
10: <%= f.submit "Unfollow", class: "btn" %>
11: <% end %>
Это мое отношение контроллер
def destroy
user = Relations.find(params[:id]).following
current_user.unfollow(user)
redirect_to user
end
моя модель пользователя
def unfollow(other_user)
following_relations.find_by(following_id: other_user.id).destroy
end
, пожалуйста, помогите мне исправить это
Какая версия Rails вы используете? find_by работает только на рельсах> = 4.0 – Santhosh
Я использую рельсы ver 3.2.19 – mayoneQD