globalize/globalize

(Object doesn't support #inspect)

qaliblog opened this issue · 2 comments

Hi, I'm trying to make a search form and when I use branch master which doesn't have Globalize gem it works but when I want to do the same search form on my double lang version it breaks and won't work because when I grep all my articles with Article.all I get this massage: (Object doesn't support #inspect)
Please show me a way to get all my articles in both languages so I can query my search.
Controller:
@articles = Article.search(params[:search]).all.paginate(page: params[:page], per_page: 5)
Model:
def self.search(query)
where("title LIKE ? OR description LIKE ?", "%#{query}%", "%#{query}%")
end

Solved...

def index
    if params[:search]
      @at = []
      @at = Array.new
      Article.translation_class.where("title LIKE ? OR description LIKE ?","%#{params[:search]}%","%#{params[:search]}%").all.each do |t|
        @at.push t.article_id
      end
      @articles = Article.where(id: @at).recent_first.paginate(page: params[:page], per_page: 5)
    else
      @articles = Article.all.recent_first.paginate(page: params[:page], per_page: 5)
    end
  end
stale commented

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.