On Aug 31, 1:09 am, ji <yanj...@gmail.com> wrote:
> in my \app\controllers\business_controller.rb:
>
> class BusinessController < ApplicationController
> def search
> @businesses = Business.search(params[:businessname], params[:city])
> end
> end
>
> in my \app\models\business.rb:
>
> class Business < ActiveRecord::Base
> def search(businessname, city)
> search_condition = "%" + businessname + "%"
> find(:all, :conditions => ['name LIKE ? AND city = ?',
> search_condition, search_condition])
> end
> end
>
> This looks like the Controller cannot find the Search function in my
> model, but apparently the function is defined there. So I am sure what
> is going on here.
You've created an instance method, but you're trying to call it as if
it was a class method (and you probably meant for city to be the
second bind variable in your call to find)
Fred
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---