Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8236563
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:10:27+00:00 2026-06-07T19:10:27+00:00

i am new in RoR. According to the book (ruby on rails 4th edition)

  • 0

i am new in RoR. According to the book (ruby on rails 4th edition) i have finish it. but i am trying to make a search option for the customers to find the product more easer. I am trying with this example http://railscasts.com/episodes/37-simple-search-form

i have put in views>store>index this:

<%= form_tag products_path, :method => 'get' do %> 
  <p>
    <%= text_field_tag :search, params[:search] %>
    <%= submit_tag "Search", :name => nil %>
  </p>
<% end %>

in the models>products i have put this:

def self.search(search)
  if search
    find(:all, :conditions => ['title LIKE ?', "%#{search}%"])
  else
    find(:all)
  end
end

and in controllers>store_controller this:

 @products = Product.search(params[:search])

the problem is when i am searching is shows me all the products i have and not only what i search and the url is changing to …../?utf8=%E2%9C%93&search=iphone+4

any ideas plz?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T19:10:28+00:00Added an answer on June 7, 2026 at 7:10 pm

    ok i found it!!! FINALLY…

    in the store_controller i was having in the def index this line : @products = Product.all and cause the problem. no the store_controller is:

    class StoreController < ApplicationController
        skip_before_filter :authorize
            @products = Product.all
      def index
        @products = Product.search(params[:search])
    
        @cart = current_cart
      end
    end
    

    AND WORKS LIKE CRAZY!

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm completely new to Ruby (and RoR) and I'm trying to set up a
im trying to understand the process of creating tables in ruby-on-rails 3. i have
i'm new with RoR and i'm trying to make a master-datail: User -Lugar(place) My
Am new to RoR paperclip gem and i have been trying out some examples
i am new to ROR, just setup the enviroment ruby 1.9.2 with rails 3.0.6
i am new at ror. option select tag in rails <%= select_tag(:city_id, '<option value=1>Lisbon</option>,<option
We are new to ROR, We have issue in creating Login/Logout process in ROR
I'm new with RoR and I have a controller ( UsersController ) where I
I'm relatively new to RoR and I'm curious about why Rails compiles assets both
This might seem a bit weird, but since I am new in RoR and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.