hello there,
I’ve just signed up to this, so apologies for the 2 questions in one
post…
please can anyone help with the following 2 issues I have? and what I
need to do to fix them?
Note - I’m quite new to rails, so if anyone can explain these, i’d be
grateful…
Question 1:
The search functionality on my application appears to have stopped
working. When I type a name in the field and hit search, I get:
''NoMethodError in BuddiesController#search
You have a nil object when you didn’t expect it!
The error occurred while evaluating nil.info ‘’
The search method is below. The line in red, is where the stack trace
led me to, but I haven’t altered anything, so unsure why it aint working
now.
def search
@title = "Find Buddies"
if params[:q]
query = params[:q]
curr_page = params[:page] || 1
users = User.find_with_ferret(query)
infos = Info.find_with_ferret(query)
hits = infos
users.concat(hits.collect { |hit| hit.user }).uniq!
users.each { |user| user.info ||= Info.new }
users = users.sort_by { |user| user.info.last_name }
@buddies = users.paginate(:page => curr_page, :per_page => 10)
end
end
Question 2:
Within my application, a user can post a comment, such as a status
update… Similar to that on Facebook and Twitter. However, whoever I
log in as, I see the same posts. I know this is probably to do with
logged_in? or sessions, but not sure how to amend it.
Can anyone help?
Many many Thanks!