Content Management in rails

Abhi Manyu wrote:

please send me the code

Let me clear my reqt once again. I have three tables users, orders and line_items. Orders table have user_id and line_items have order_id. Now the following code is giving error: uninitialized constant UserController::Line_items

def search   @orders = Order.find :all

this is horribly inefficient

    session[:query] = params[:query].strip if params[:query]     if session[:query] and request.xhr?      @users = User.find(:all, :conditions => ["first_name LIKE ?", "%#{session[:query]}%"], :order => "first_name ASC")     @product=Array.new      @users.each do |user|        @orders.each do |order|          if user.id == order.user_id            @id = order.id         @var = Line_items.find_by_order_id(@id)

find_by_x is like a find :first. You probably want find_all_by_x The class name is LineItem (if you're adhering to the usual conventions). If you've defined your relationships properly, you could do something along the lines of

@product = @users.collect {|u| u.orders.collect(&:line_items)}.flatten

(eager loading those associations might be a good idea)

You seem to be stumbling over some really basic rails stuff. Find a good book on rails and read and understand it. AWDWR is a popular favourite, and there's a book you can get for free at http://www.sitepoint.com/books/rails1/freebook.php

Fred