0
我正試圖在用Mongool的Rails上創建用戶之間的聯繫。控制檯顯示一個SyntaxError本:RoR上的關閉語句
MyApp/app/controllers/contact_controller.rb:18: syntax error, unexpected end-of-input, expecting keyword_end
這是控制器:
class ContactController < ApplicationController
def addNew
@newFriend = params[:username]
puts "***value of @newFriend***"
puts @newFriend
puts "***end****"
Contact.where(owner: current_user).where(friendlist: params[:username]) do |contact|
puts "***value of @contactAlreadyExists***"
puts contact
puts "***end****"
if contact == nil
Contact.find_or_create_by(owner: current_user) do |contact|
contact.push(friendlist: params[:username])
end
redirect_to "/"
end
end
,這是模型:
class Contact
include Mongoid::Document
include Mongoid::Timestamps
field :owner, :type => String
field :friendlist, :type => Array
embedded_in :users
end
這是,現在只需要檢查用戶的好友列表中是否有聯繫人。 –