Problem with the Search Function in chapter 4

4 views
Skip to first unread message

yorks....@googlemail.com

unread,
May 20, 2008, 9:33:34 AM5/20/08
to Beginning Ruby on Rails E-Commerce
Hi again

sorry to be a pain but I'm having yet more problems I have followed
the code to the letter for using the find_by_contents method but when
i try running the search as it says I should be able to in the book I
keep getting the following error :

NoMethodError in CatalogController#search
undefined method `find_by_contents' for Book:Class

here is the code I have added to my catalog_controller.rb:

def search
@page_title = "Search"
if params[:commit] == "Search" || params[:q]
@books = Book.find_by_contents(params[:q].to_s.upcase)
unless @books.size > 0
flash.now[:notice] = "No books found matching your criteria"
end
end
end

thanks in advance for your help :)

Lee

yorks....@googlemail.com

unread,
May 20, 2008, 9:42:32 AM5/20/08
to Beginning Ruby on Rails E-Commerce

Jarkko Laine

unread,
May 20, 2008, 10:34:06 AM5/20/08
to railsec...@googlegroups.com
Hi Lee,

It seems that the name of the method used by ActsAsFerret has been
changed to find_with_ferret after the book was published. Can you
replace all instances of find_by_contents with find_with_ferret and
see if that works for you?

Cheers,
//jarkko

> --~--~---------~--~----~------------~-------~--~----~
> You received this message because you are subscribed to the Google
> Groups "Beginning Ruby on Rails E-Commerce" group.
> To post to this group, send email to railsec...@googlegroups.com
> To unsubscribe from this group, send email to railsecommerc...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/railsecommerce?hl=en
> -~----------~----~----~----~------~----~------~--~---
>

--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


yorks....@googlemail.com

unread,
May 20, 2008, 10:52:28 AM5/20/08
to Beginning Ruby on Rails E-Commerce
thanks very much Jarkko

that has worked perfectly, thanks very much.

out of interest is there any way of finding out about these kind of
changes??? as i tried googling for quite some time and couldnt find
anything.

Thanks
Lee

On May 20, 3:34 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> Hi Lee,
>
> It seems that the name of the method used by ActsAsFerret has been
> changed to find_with_ferret after the book was published. Can you
> replace all instances of find_by_contents with find_with_ferret and
> see if that works for you?
>
> Cheers,
> //jarkko
>
> On 20.5.2008, at 16.33, yorks.terr...@googlemail.com wrote:
>
>
>
>
>
> > Hi again
>
> > sorry to be a pain but I'm having yet more problems I have followed
> > the code to the letter for using the find_by_contents method but when
> > i try running the search as it says I should be able to in the book I
> > keep getting the following error :
>
> > NoMethodError in CatalogController#search
> > undefined method `find_by_contents' for Book:Class
>
> > here is the code I have added to my catalog_controller.rb:
>
> > def search
> > @page_title = "Search"
> > if params[:commit] == "Search" || params[:q]
> > @books = Book.find_by_contents(params[:q].to_s.upcase)
> > unless @books.size > 0
> > flash.now[:notice] = "No books found matching your criteria"
> > end
> > end
> > end
>
> > thanks in advance for your help :)
>
> > Lee
> > >
> --
> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce.comhttp://odesign.fi
>
> smime.p7s
> 3KDownload

yorks....@googlemail.com

unread,
May 20, 2008, 10:57:18 AM5/20/08
to Beginning Ruby on Rails E-Commerce
hmmm correction the search function is now sort of wrorking, however
its not finding any of the test books i have entered into the
database.

any ideas why??

Lee

On May 20, 3:34 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> Hi Lee,
>
> It seems that the name of the method used by ActsAsFerret has been
> changed to find_with_ferret after the book was published. Can you
> replace all instances of find_by_contents with find_with_ferret and
> see if that works for you?
>
> Cheers,
> //jarkko
>
> On 20.5.2008, at 16.33, yorks.terr...@googlemail.com wrote:
>
>
>
>
>
> > Hi again
>
> > sorry to be a pain but I'm having yet more problems I have followed
> > the code to the letter for using the find_by_contents method but when
> > i try running the search as it says I should be able to in the book I
> > keep getting the following error :
>
> > NoMethodError in CatalogController#search
> > undefined method `find_by_contents' for Book:Class
>
> > here is the code I have added to my catalog_controller.rb:
>
> > def search
> > @page_title = "Search"
> > if params[:commit] == "Search" || params[:q]
> > @books = Book.find_by_contents(params[:q].to_s.upcase)
> > unless @books.size > 0
> > flash.now[:notice] = "No books found matching your criteria"
> > end
> > end
> > end
>
> > thanks in advance for your help :)
>
> > Lee
> > >

yorks....@googlemail.com

unread,
May 20, 2008, 10:57:43 AM5/20/08
to Beginning Ruby on Rails E-Commerce
hmmm correction the search function is now sort of wrorking, however
its not finding any of the test books i have entered into the
database.

any ideas why??

Lee

On May 20, 3:34 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> Hi Lee,
>
> It seems that the name of the method used by ActsAsFerret has been
> changed to find_with_ferret after the book was published. Can you
> replace all instances of find_by_contents with find_with_ferret and
> see if that works for you?
>
> Cheers,
> //jarkko
>
> On 20.5.2008, at 16.33, yorks.terr...@googlemail.com wrote:
>
>
>
>
>
> > Hi again
>
> > sorry to be a pain but I'm having yet more problems I have followed
> > the code to the letter for using the find_by_contents method but when
> > i try running the search as it says I should be able to in the book I
> > keep getting the following error :
>
> > NoMethodError in CatalogController#search
> > undefined method `find_by_contents' for Book:Class
>
> > here is the code I have added to my catalog_controller.rb:
>
> > def search
> > @page_title = "Search"
> > if params[:commit] == "Search" || params[:q]
> > @books = Book.find_by_contents(params[:q].to_s.upcase)
> > unless @books.size > 0
> > flash.now[:notice] = "No books found matching your criteria"
> > end
> > end
> > end
>
> > thanks in advance for your help :)
>
> > Lee
> > >

yorks....@googlemail.com

unread,
May 20, 2008, 11:02:56 AM5/20/08
to Beginning Ruby on Rails E-Commerce
hmmm correction the search function is now sort of wrorking, however
its not finding any of the test books i have entered into the
database.

any ideas why??

Lee

On May 20, 3:34 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> Hi Lee,
>
> It seems that the name of the method used by ActsAsFerret has been
> changed to find_with_ferret after the book was published. Can you
> replace all instances of find_by_contents with find_with_ferret and
> see if that works for you?
>
> Cheers,
> //jarkko
>
> On 20.5.2008, at 16.33, yorks.terr...@googlemail.com wrote:
>
>
>
>
>
> > Hi again
>
> > sorry to be a pain but I'm having yet more problems I have followed
> > the code to the letter for using the find_by_contents method but when
> > i try running the search as it says I should be able to in the book I
> > keep getting the following error :
>
> > NoMethodError in CatalogController#search
> > undefined method `find_by_contents' for Book:Class
>
> > here is the code I have added to my catalog_controller.rb:
>
> > def search
> > @page_title = "Search"
> > if params[:commit] == "Search" || params[:q]
> > @books = Book.find_by_contents(params[:q].to_s.upcase)
> > unless @books.size > 0
> > flash.now[:notice] = "No books found matching your criteria"
> > end
> > end
> > end
>
> > thanks in advance for your help :)
>
> > Lee
> > >

Jarkko Laine

unread,
May 20, 2008, 11:05:09 AM5/20/08
to railsec...@googlegroups.com

On 20.5.2008, at 17.52, yorks....@googlemail.com wrote:

>
> thanks very much Jarkko
>
> that has worked perfectly, thanks very much.
>
> out of interest is there any way of finding out about these kind of
> changes??? as i tried googling for quite some time and couldnt find
> anything.

I'm updating the errata page (http://railsecommerce.com/errata) as I'm
finding out about these changes.

//jarkko

Jarkko Laine

unread,
May 20, 2008, 11:07:54 AM5/20/08
to railsec...@googlegroups.com

On 20.5.2008, at 17.57, yorks....@googlemail.com wrote:

>
> hmmm correction the search function is now sort of wrorking, however
> its not finding any of the test books i have entered into the
> database.

Does it find books you enter now? I don't know if it automatically
indexes books that already exist in the database (but I might be
wrong). Try if running Book.rebuild_index in the console helps.

//jarkko

yorks....@googlemail.com

unread,
May 20, 2008, 11:09:30 AM5/20/08
to Beginning Ruby on Rails E-Commerce
thats good jarkko

but I was meaning more in terms of what sources do you use to for
instance find out that find_by_contents has since been changed to
find_with_ferret?

Lee

On May 20, 4:05 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> >> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....
> >> ://odesign.fi
>
> >> smime.p7s
> >> 3KDownload

Jarkko Laine

unread,
May 20, 2008, 11:09:29 AM5/20/08
to railsec...@googlegroups.com
Oh, and Gmail never shows you the messages you send yourself, so you
might want to check from the group website whether your message has
arrived if you fear it didn't get through. Your last mail arrived here
three times ;-)

//jarkko

Jarkko Laine

unread,
May 20, 2008, 11:14:38 AM5/20/08
to railsec...@googlegroups.com
On 20.5.2008, at 18.09, yorks....@googlemail.com wrote:

>
> thats good jarkko
>
> but I was meaning more in terms of what sources do you use to for
> instance find out that find_by_contents has since been changed to
> find_with_ferret?

If something that's a part of a plugin (in this case acts_as_ferret)
doesn't work, there's ultimately three options:

1) you haven't installed the plugin
2) you are not using the plugin (calling acts_as_ferret in the Book
model in this case) correctly.
3) The plugin api has changed.

Since you said you followed the book by the letter, I checked the
plugin's website (http://projects.jkraemer.net/acts_as_ferret/) and
found out (in the introductory tutorial) that they didn't use a method
called find_by_contents anymore. The same can be found in the plugin's
API docs: http://projects.jkraemer.net/rdoc/acts_as_ferret/

In general, Google is your friend.

//jarkko

yorks....@googlemail.com

unread,
May 20, 2008, 11:16:07 AM5/20/08
to Beginning Ruby on Rails E-Commerce
I had noticed that my messages were showing up on here more than once
and I have no diea why as I've only sent the message once.



On May 20, 4:09 pm, Jarkko Laine <jar...@jlaine.net> wrote:
> Oh, and Gmail never shows you the messages you send yourself, so you
> might want to check from the group website whether your message has
> arrived if you fear it didn't get through. Your last mail arrived here
> three times ;-)
>
> //jarkko
>
> >> Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....
> >> ://odesign.fi
>
> >> smime.p7s
> >> 3KDownload

yorks....@googlemail.com

unread,
May 22, 2008, 5:26:16 AM5/22/08
to Beginning Ruby on Rails E-Commerce
Hi Jarkko

for some reason find_with_ferret doesnt seem to be working properly,

I have tried performing a couple of test searches for some sample
books i have entered but it is not finding anything even when i copy
the book title and paste it into the search box, any ideas why this
might be??

thanks very much

Lee

On May 20, 4:16 pm, "yorks.terr...@googlemail.com"
> > Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....
>
> > smime.p7s
> > 3KDownload

yorks....@googlemail.com

unread,
May 22, 2008, 5:40:16 AM5/22/08
to Beginning Ruby on Rails E-Commerce
Hi Jarkko

for some reason find_with_ferret doesnt seem to be working properly,

I have tried performing a couple of test searches for some sample
books i have entered but it is not finding anything even when i copy
the book title and paste it into the search box, any ideas why this
might be??

thanks very much

Lee

On May 20, 4:16 pm, "yorks.terr...@googlemail.com"
<yorks.terr...@googlemail.com> wrote:
> > Jarkko Lainehttp://jlaine.nethttp://dotherightthing.comhttp://www.railsecommerce....
>
> > smime.p7s
> > 3KDownload

Jarkko Laine

unread,
May 22, 2008, 7:13:52 AM5/22/08
to railsec...@googlegroups.com

On 22.5.2008, at 12.40, yorks....@googlemail.com wrote:

>
> Hi Jarkko
>
> for some reason find_with_ferret doesnt seem to be working properly,
>
> I have tried performing a couple of test searches for some sample
> books i have entered but it is not finding anything even when i copy
> the book title and paste it into the search box, any ideas why this
> might be??

Sorry, no idea if you already rebuilt the index. You might to ask for
help in the acts_as_ferret forums.

//jarkko

Reply all
Reply to author
Forward
0 new messages