I have the following controller code:
def index
@profiles = Profile.where("(first_name || ' ' || last_name) ILIKE ?", "%#{params[:q]}%")
@autolist = []
@profiles.each do |profile|
user = User.find_by_id(profile.user_id)
@autolist.concat([{"id",profile.id,"name",profile.first_name+" "+profile.last_name,"email",user.email}])
end
respond_to do |format|
format.html # index.html.erb
format.json { render :json => @autolist }
end
end
It works in my local environment, but crashes my app. Specifically this line: @autolist.concat([{"id",profile.id,"name",profile.first_name+" "+profile.last_name,"email",user.email}])
Any ideas?
I have a feeling it has to do with my local env using ruby 1.8.7 and the heroku app running 1.9.2
This works in 1.8.7:
but not in 1.9.2:
The rocket notation will serve you better:
I can’t find any mention of this change in the 1.9.1 or 1.9.2 release notes and this is actually the first time I’ve seen the
{'a', b}syntax for a Ruby Hash. Perhaps that notation was a deprecated feature that finally went away.BTW, developing on 1.8.7 and deploying on 1.9.2 isn’t the best idea.