Content Management in rails

3 views
Skip to first unread message

Ruchita Sharma

unread,
Nov 5, 2007, 7:24:54 AM11/5/07
to rubyonra...@googlegroups.com
Hi,


Can someone tell me how to manage the content in Admin panel? I have to
implement Content Management System in the admin panel.... but not
getting any idea of how to implement it.


Any help would be greatly appreciated.

Thanks,
Ruchita Sharma.
--
Posted via http://www.ruby-forum.com/.

Mohit Sindhwani

unread,
Nov 5, 2007, 8:22:30 AM11/5/07
to rubyonra...@googlegroups.com
Ruchita Sharma wrote:
> Hi,
>
>
> Can someone tell me how to manage the content in Admin panel? I have to
> implement Content Management System in the admin panel.... but not
> getting any idea of how to implement it.
>
>
> Any help would be greatly appreciated.
>
> Thanks,
> Ruchita Sharma.
>

What admin panel? If you're looking for content management, there are a
few CMS solutions implemented in Rails. Radiant is one and you can find
a number more if you search the archives for this group/ mailing list.

Cheers,
Mohit.
11/5/2007 | 9:21 PM.

Ruchita Sharma

unread,
Nov 5, 2007, 8:28:15 AM11/5/07
to rubyonra...@googlegroups.com
Mohit Sindhwani wrote:

> Ruchita Sharma wrote:
>> Thanks,
>> Ruchita Sharma.
>>
>
> What admin panel? If you're looking for content management, there are a
> few CMS solutions implemented in Rails. Radiant is one and you can find
> a number more if you search the archives for this group/ mailing list.
>
> Cheers,
> Mohit.
> 11/5/2007 | 9:21 PM.

yeah i have looked Radiant.... but not able to work it properly coz the
link that i am following does not give the exact description of how to
use it. I have also tried admin_pages_engine but again not able to
implement it properly. Can you tell me some other option???

Mohit Sindhwani

unread,
Nov 5, 2007, 8:32:53 AM11/5/07
to rubyonra...@googlegroups.com

What do you mean that Radiant is not able to work properly? It seems to
work absolutely fine for a couple of sites that I'm managing. The
documentation site on the Radiant site includes links to a few tutorials
that should help you get started.

Of course, a lot depends on what you want to do and what is required of
the site that you're designing. I don't think anyone can give you an
option if you're not clear (and don't tell us) what needs to be implemented.

Ruchita Sharma

unread,
Nov 5, 2007, 8:39:41 AM11/5/07
to rubyonra...@googlegroups.com
Mohit Sindhwani wrote:
> Ruchita Sharma wrote:
>>> a number more if you search the archives for this group/ mailing list.
>>
> What do you mean that Radiant is not able to work properly? It seems to
> work absolutely fine for a couple of sites that I'm managing. The
> documentation site on the Radiant site includes links to a few tutorials
> that should help you get started.
>
> Of course, a lot depends on what you want to do and what is required of
> the site that you're designing. I don't think anyone can give you an
> option if you're not clear (and don't tell us) what needs to be
> implemented.

Hi...

I am using this link "http://www.radiantcms.org/download/" U can check
that in this link when we click on install instructions it gives an
error. So I am not able to do the exact implementation.

Mohit Sindhwani

unread,
Nov 5, 2007, 8:46:37 AM11/5/07
to rubyonra...@googlegroups.com

The documentation is being migrated to another wiki. You can find all
the documentation for Radiant on the documentation site:
http://wiki.radiantcms.org/Documentation

Installation: http://wiki.radiantcms.org/Installation

Also, there are how-to articles and also tutorials. Just start at the
documentation page.

Cheers,
Mohit.
11/5/2007 | 9:46 PM.


Abhi Manyu

unread,
Nov 5, 2007, 10:24:52 PM11/5/07
to rubyonra...@googlegroups.com
Hi Ruchita

Good Morning

Did you get any soln?

Abhi Manyu

unread,
Nov 5, 2007, 10:51:29 PM11/5/07
to rubyonra...@googlegroups.com

Hi Ruchita
there are other cms other than radiant . They are

Mephisto,typo3 ,...
Here are some links

how to install radiant cms
->http://kb.mediatemple.net/article.php?id=152
deploying mephisto cms ->
https://support.railsmachine.com/index.php?pg=kb.page&id=13
http://mephisto.stikipad.com/help/
typo3->http://typo3.com/
http://typo3.blinklist.com/
cms tutorial -> http://www.rubyonrailscamp.com/Rails+CMS+Tutorial
http://www.rubymatters.com/ruby-cms.shtml

Ruchita Sharma

unread,
Nov 5, 2007, 11:13:45 PM11/5/07
to rubyonra...@googlegroups.com

hi Abhimanyu,


Good Morning. Didn't get any soln yet. Wud try the links and let you
know.

Abhi Manyu

unread,
Nov 6, 2007, 3:32:37 AM11/6/07
to rubyonra...@googlegroups.com
Hi
How is going

Ruchita Sharma

unread,
Nov 6, 2007, 3:37:45 AM11/6/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi
> How is going

Hi....Actually now am trying to implement CMS with fckeditor abut facing
a little difficulty. Have u ever used fckeditor with rails??

Abhi Manyu

unread,
Nov 6, 2007, 4:43:53 AM11/6/07
to rubyonra...@googlegroups.com
Hi
Sorry I havent used it till now. But I have heard of it as been used to
write html and other things.
But are you using it as ide. I am using aptana as ide

Ruchita Sharma

unread,
Nov 6, 2007, 6:38:42 AM11/6/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi
> Sorry I havent used it till now. But I have heard of it as been used to
> write html and other things.
> But are you using it as ide. I am using aptana as ide

Wats aptana? Are you using it for content management???

Abhi Manyu

unread,
Nov 6, 2007, 6:39:52 AM11/6/07
to rubyonra...@googlegroups.com
Aptana is an ide used for ror. I am using it for a project not sure
whether its cms

Abhi Manyu

unread,
Nov 6, 2007, 6:52:06 AM11/6/07
to rubyonra...@googlegroups.com
Ok Bye for today.You can also mail me I will check tomorrow if you need
my help

Bye

Ruchita Sharma

unread,
Nov 6, 2007, 6:54:32 AM11/6/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Ok Bye for today.You can also mail me I will check tomorrow if you need
> my help
>
> Bye

yeah sure..... bbye

CCH

unread,
Nov 6, 2007, 7:02:12 AM11/6/07
to Ruby on Rails: Talk
Hi Ruchita

Aptana Radrails is an IDE for Rails Project Management and more...
However, AFAIK, it s not a CMS :-)

CCH
http://cch4rails.blogspot.com

Ruchita Sharma

unread,
Nov 6, 2007, 7:06:33 AM11/6/07
to rubyonra...@googlegroups.com

Can you tell me how to use FckEditor for CMS?

Abhi Manyu

unread,
Nov 6, 2007, 9:46:07 PM11/6/07
to rubyonra...@googlegroups.com

Ruchita Sharma

unread,
Nov 6, 2007, 11:13:54 PM11/6/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi
>
> Good Morning
> Have you check these
>
> http://www.webmasterworld.com/content_management/3351469.htm
>
> http://www.megite.com/url/:www_onlamp_com/pub/a/onlamp/2006/04/20/from-weblog-to-cms.html
> http://joshuamcharles.com/xhtml/fckrails.php
>
> Third one is a popular link
>
> Do you have deepavali holiday

Good Morning,


Let me try these links.... wud let u know. Yes we have holidays on
friday,sat and sunday.

Ruchita Sharma

unread,
Nov 7, 2007, 12:31:16 AM11/7/07
to rubyonra...@googlegroups.com

Hi Abhimanyu,

I have implemented it with fckeditor by saving saving in the database.
Tell me one thing how can we create a activate or deactivate button in
rails.

Abhi Manyu

unread,
Nov 7, 2007, 12:47:19 AM11/7/07
to rubyonra...@googlegroups.com
Hi Ruchita

this is a code that I got . this is to hide a text box.try this for
button
<input type=text id=text1>
<input type=button value=hide onclick=hide()>
<input type=button value=show onclick=show()>
<script type=text/javascript>
function hide(){
document.getElementById('text1').style.visibility='hidden';
}
function show(){
document.getElementById('text1').style.visibility='visible';
}
</script>

Ruchita Sharma

unread,
Nov 7, 2007, 12:52:48 AM11/7/07
to rubyonra...@googlegroups.com

Thanks for that Abhimanyu.
But I mean to say that.... how can we implement the functionality that
on clicking of a button admin can activate or deactivate the status of a
user.

I have to implement the functionality where the list of users is coming
and the admin can activate or deactivate the status of a user.

Abhi Manyu

unread,
Nov 7, 2007, 12:59:32 AM11/7/07
to rubyonra...@googlegroups.com
Have a button in the view and in the admin controller/action try the
following code
User.update(params[id].to_i, :status => "inactive")

User ->table containing list of users

Ruchita Sharma

unread,
Nov 7, 2007, 2:25:18 AM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Have a button in the view and in the admin controller/action try the
> following code
> User.update(params[id].to_i, :status => "inactive")
>
> User ->table containing list of users

Hi, Thanks a lot Abhimanyu. Its working :)

Abhi Manyu

unread,
Nov 7, 2007, 2:31:53 AM11/7/07
to rubyonra...@googlegroups.com
Hi Ruchita

I am very much happy for you.
By the way Happy Deepavali
I dont have a holiday

Ruchita Sharma

unread,
Nov 7, 2007, 2:34:27 AM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi Ruchita
>
> I am very much happy for you.
> By the way Happy Deepavali
> I dont have a holiday


Thanks a lot. Why you dont have a holiday on Diwali?? That's sad :(

Happy Diwali to you too....

Abhi Manyu

unread,
Nov 7, 2007, 3:01:16 AM11/7/07
to rubyonra...@googlegroups.com
Hi Ruchita

Which IDE are you using. Are you a fresher in IT

Ruchita Sharma

unread,
Nov 7, 2007, 3:10:47 AM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi Ruchita
>
> Which IDE are you using. Are you a fresher in IT

Am not working on any IDE. Using Jedit as an editor. I have an
experience of approximatly 1 year in IT but in Ruby around 5 months.

Abhi Manyu

unread,
Nov 7, 2007, 4:32:08 AM11/7/07
to rubyonra...@googlegroups.com
Does jEdit provides intellisense. what are its features and what is its
interface(console or gui)?

Ruchita Sharma

unread,
Nov 7, 2007, 5:17:05 AM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Does jEdit provides intellisense. what are its features and what is its
> interface(console or gui)?

yeah jEdit provides intellisense. Its interface is gui. On which project
u r workin?

Abhi Manyu

unread,
Nov 7, 2007, 5:31:49 AM11/7/07
to rubyonra...@googlegroups.com
I am working on hospital management type project. Before 5 months on
which technology were you working

Abhi Manyu

unread,
Nov 7, 2007, 6:43:47 AM11/7/07
to rubyonra...@googlegroups.com
OK Bye for today

Ruchita Sharma

unread,
Nov 7, 2007, 6:46:08 AM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> OK Bye for today

Okie bbye.

Abhi Manyu

unread,
Nov 7, 2007, 9:18:45 PM11/7/07
to rubyonra...@googlegroups.com
Hi Good Morning

How are you today. Whats the new task for you?

Ruchita Sharma

unread,
Nov 7, 2007, 11:13:18 PM11/7/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi Good Morning
>
> How are you today. Whats the new task for you?

Good Morning.

Well I have to implement the functionality to display thumbnail images
that I told you.

Abhi Manyu

unread,
Nov 7, 2007, 11:21:42 PM11/7/07
to rubyonra...@googlegroups.com
Oh Ok
I have send you a mail.
Did you get any solutions for the task?
On which technology were you working before 5 months?

Abhi Manyu

unread,
Nov 8, 2007, 2:32:08 AM11/8/07
to rubyonra...@googlegroups.com
Hi
Okay then have a great and happy holidays

Ruchita Sharma

unread,
Nov 8, 2007, 2:34:26 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi
> Okay then have a great and happy holidays

I have uploaded the image in two sizes thumbnail and inline but am not
able to display the thumbnail image..... trying for that. Wud let u
knw....

Abhi Manyu

unread,
Nov 8, 2007, 2:51:23 AM11/8/07
to rubyonra...@googlegroups.com
okay All the Best

tell me if you need my help

Ruchita Sharma

unread,
Nov 8, 2007, 2:55:42 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> okay All the Best
>
> tell me if you need my help

yeah i need your help. I really dont knw how to display the thumbnail
image. I am saving the images in the temp folder and now am not able to
display the thumbnail image.

Mohit Sindhwani

unread,
Nov 8, 2007, 3:19:07 AM11/8/07
to rubyonra...@googlegroups.com
Ruchita Sharma wrote:
> Abhi Manyu wrote:
>
>> okay All the Best
>>
>> tell me if you need my help
>>
>
> yeah i need your help. I really dont knw how to display the thumbnail
> image. I am saving the images in the temp folder and now am not able to
> display the thumbnail image.
>

Why don't you use something like file_column or attachment_fu?
There's plenty of stuff on the internet on how to use file_column for
uploading images, creating thumbnails (you don't need to upload a
separate thumbnail) and displaying it all.

Take a look at the main home page for file_column - the code is there:
http://www.kanthak.net/opensource/file_column/

This shows how to display thumbnails:
http://wiki.rubyonrails.org/rails/pages/HowToUseFileColumn

Regards
Mohit.


Abhi Manyu

unread,
Nov 8, 2007, 3:23:51 AM11/8/07
to rubyonra...@googlegroups.com
I usually store images in public\images folder.rails will automatically
take the image from there
However let me see if there is another way. I will check and will send
you asap

Abhi Manyu

unread,
Nov 8, 2007, 3:25:48 AM11/8/07
to rubyonra...@googlegroups.com
are you using instant rails?
it gives a better folder structure

Ruchita Sharma

unread,
Nov 8, 2007, 3:28:34 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> are you using instant rails?
> it gives a better folder structure

No am not using dt.

Abhi Manyu

unread,
Nov 8, 2007, 3:36:51 AM11/8/07
to rubyonra...@googlegroups.com
controller, models, helpers and views are in a folder called apps
Like that there is a folder called public where images are stored in
images foldr

Mohit Sindhwani

unread,
Nov 8, 2007, 3:39:16 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> controller, models, helpers and views are in a folder called apps
> Like that there is a folder called public where images are stored in
> images foldr
>
That's not because of InstantRails - that's the convention that Rails
follows.

Cheers,
Mohit.
11/8/2007 | 4:39 PM.


Abhi Manyu

unread,
Nov 8, 2007, 3:41:59 AM11/8/07
to rubyonra...@googlegroups.com
so try storing the images in images folder and you just have to call the
names

Abhi Manyu

unread,
Nov 8, 2007, 3:49:27 AM11/8/07
to rubyonra...@googlegroups.com
tell me whether you saw the public/images folder

Ruchita Sharma

unread,
Nov 8, 2007, 4:18:21 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> tell me whether you saw the public/images folder

Hi... yes i have that folder. But I have defined the path in my upload
model. FILE_STORE_PATH = File.join(File.dirname(__FILE__), '/../temp/').
So images are saved in temp folder.

Abhi Manyu

unread,
Nov 8, 2007, 4:22:37 AM11/8/07
to rubyonra...@googlegroups.com
Thing is if sometimes the path is outside the project folder structure
it wont accept . This case is not only for ror but also for other
technologies also. Let me check and I will notify you asap

Ruchita Sharma

unread,
Nov 8, 2007, 4:25:28 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Thing is if sometimes the path is outside the project folder structure
> it wont accept . This case is not only for ror but also for other
> technologies also. Let me check and I will notify you asap

path is obviously inside the project folder. Its in app folder.

Abhi Manyu

unread,
Nov 8, 2007, 4:35:43 AM11/8/07
to rubyonra...@googlegroups.com
so did you created that temp folder
what i mean as resources folder in .net here it is public/images folder
which is the default so try that
here In the following link path is given in diff way I think

http://blog.airbladesoftware.com/2007/6/20/how-to-store-thumbnails-and-full-size-images-in-different-directories-with-attachment_fu

Peter Bengtson

unread,
Nov 8, 2007, 4:38:38 AM11/8/07
to rubyonra...@googlegroups.com
Why don't you take this discussion off-list, or concentrate it to
fewer but longer post? This sort of ping-pong of short messages is not
really helpful to a wider audience.

Abhi Manyu

unread,
Nov 8, 2007, 4:44:48 AM11/8/07
to rubyonra...@googlegroups.com
Hi check this site . this is also good for reference as well as learning
http://www.tutorialspoint.com/ruby-on-rails/rails-directory-structure.htm

Abhi Manyu

unread,
Nov 8, 2007, 4:55:52 AM11/8/07
to rubyonra...@googlegroups.com
also give a serach to this forum itself you may get some idea
like this one
http://www.ruby-forum.com/topic/129946#new

Ruchita Sharma

unread,
Nov 8, 2007, 6:22:27 AM11/8/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> also give a serach to this forum itself you may get some idea
> like this one
> http://www.ruby-forum.com/topic/129946#new

Can anybdy help me out? I am using the following tutorails for image
uploading and displaying:
http://khamsouk.souvanlasy.com/2007/5/1/ajax-file-uploads-in-rails-using-attachment_fu-and-responds_to_parent

But i am getting the error

SystemExit in AssetsController#new

exit

Mislav

unread,
Nov 8, 2007, 7:57:30 AM11/8/07
to Ruby on Rails: Talk
On Nov 8, 10:38 am, Peter Bengtson <pe...@peterbengtson.com> wrote:
> Why don't you take this discussion off-list, or concentrate it to
> fewer but longer post? This sort of ping-pong of short messages is not
> really helpful to a wider audience.

I must agree with Peter. First, half of this thread is personal
conversation between Abhi and Ruchita and should be taken off this
list. Second, the Rails-related talk is beginning to look more like
chat. You guys should try using IRC and join #rubyonrails on freenode.

Ruchita Sharma

unread,
Nov 12, 2007, 6:28:39 AM11/12/07
to rubyonra...@googlegroups.com

Hi,

I need to select the last row from the database. For that am writing the
code:
@sorter = SortingHelper::Sorter.new self, %w(id), params[:id], 'id',
'DESC'
sort_by = params[:sort]
@content = Content.find :all, :order => sort_by, :limit => 1

but this coding is returning the value (#).
Can anyone tell me where i am wrong?

Any help would be greatly appreciated.


Thanks,
Ruchita

Abhi Manyu

unread,
Nov 12, 2007, 6:50:54 AM11/12/07
to rubyonra...@googlegroups.com
try this

@content = Content.find (:all,:order => 'nameof the column DESC')
eg
if name of column is "name"
@content = Content.find (:all,:order => 'name DESC')

Ruchita Sharma

unread,
Nov 12, 2007, 7:27:28 AM11/12/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> try this
>
> @content = Content.find (:all,:order => 'nameof the column DESC')
> eg
> if name of column is "name"
> @content = Content.find (:all,:order => 'name DESC')

Thanks a lot. It worked.

Ruchita Sharma

unread,
Nov 13, 2007, 5:38:37 AM11/13/07
to rubyonra...@googlegroups.com
Ruchita Sharma wrote:
> Abhi Manyu wrote:
>> try this
>>
>> @content = Content.find (:all,:order => 'nameof the column DESC')
>> eg
>> if name of column is "name"
>> @content = Content.find (:all,:order => 'name DESC')
>
> Thanks a lot. It worked.

Hi Abhimanyu,

I am implementing the functionality where i have to display the products
details as per user id. I have three tables users table, orders table
and line_items table. The fields are:

users table: id,first_name and so on.
orders table: id, user_id, first_name and so on.
line_items table: id, order_id, product_id, quantity and so on.

Now from these tables i have to display the product_id, quantity..... as
per user id. Please tell me how to implement this.

Abhi Manyu

unread,
Nov 13, 2007, 5:58:50 AM11/13/07
to rubyonra...@googlegroups.com
one way is to write the like
@order = Order.find_by_user_id("userid")->fill the "userid"

@product = Line_items.find_by_order_id("orderid")-fill the "orderid"
if there are more than one orders then

@product=Array.new
@orders = Order.find_by_user_id("userid")->fill the "userid"
@orders.each do |order|
@var = Line_items.find_by_order_id(order)
@product << @var
end

@product will have all the products that the user have ordered

Ruchita Sharma

unread,
Nov 13, 2007, 6:29:12 AM11/13/07
to rubyonra...@googlegroups.com

it is throwing an error:

NoMethodError in UserController#search

undefined method `each' for #<Order:0x4723338>

Abhi Manyu

unread,
Nov 13, 2007, 6:30:51 AM11/13/07
to rubyonra...@googlegroups.com
please send me the code

Ruchita Sharma

unread,
Nov 13, 2007, 6:38:45 AM11/13/07
to rubyonra...@googlegroups.com
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
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)
@product << @var
render_text "a"
else
render_text "abc"
end
end
end
end

Frederick Cheung

unread,
Nov 13, 2007, 6:52:16 AM11/13/07
to rubyonra...@googlegroups.com

On 13 Nov 2007, at 11:38, Ruchita Sharma wrote:

>
> 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

Abhi Manyu

unread,
Nov 13, 2007, 6:53:03 AM11/13/07
to rubyonra...@googlegroups.com
there are associations between all these tables rt? . also you alsop
want to have all the products of a particular user rt?
please let me know and if possible send the whole error code

Abhi Manyu

unread,
Nov 13, 2007, 6:55:29 AM11/13/07
to rubyonra...@googlegroups.com
Hi check whether Line_items is the class name

Ruchita Sharma

unread,
Nov 13, 2007, 7:04:32 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hi check whether Line_items is the class name

I have defined all the associations. In line_item model i have defined
belongs_to :order and in order model I have defined belongs_to :user.
The error is:

NameError in UserController#search

uninitialized constant UserController::Line_items

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/active_support/dependencies.rb:477:in
`const_missing'
C:/rails/herbaltea/app/controllers/user_controller.rb:88:in `search'
C:/rails/herbaltea/app/controllers/user_controller.rb:85:in `each'
C:/rails/herbaltea/app/controllers/user_controller.rb:85:in `search'
C:/rails/herbaltea/app/controllers/user_controller.rb:84:in `each'
C:/rails/herbaltea/app/controllers/user_controller.rb:84:in `search'

Abhi Manyu

unread,
Nov 13, 2007, 7:07:23 AM11/13/07
to rubyonra...@googlegroups.com
Did u check the class name is it Line_items itself or LineItems or
Line_Items.
Mean while I will check if there is any other errror . do let me know

Frederick Cheung

unread,
Nov 13, 2007, 7:08:08 AM11/13/07
to rubyonra...@googlegroups.com

On 13 Nov 2007, at 12:04, Ruchita Sharma wrote:

>
> Abhi Manyu wrote:
>> Hi check whether Line_items is the class name
>
> I have defined all the associations. In line_item model i have defined
> belongs_to :order and in order model I have defined belongs_to :user.
> The error is:
>
> NameError in UserController#search
>

Like I said before, if you are adhering to the conventions, the class
name is LineItem, not line_item or Line_item or Line_items

Fred

Ruchita Sharma

unread,
Nov 13, 2007, 7:14:17 AM11/13/07
to rubyonra...@googlegroups.com
Frederick Cheung wrote:
> On 13 Nov 2007, at 12:04, Ruchita Sharma wrote:
>
>>
>> Abhi Manyu wrote:
>>> Hi check whether Line_items is the class name
>>
>> I have defined all the associations. In line_item model i have defined
>> belongs_to :order and in order model I have defined belongs_to :user.
>> The error is:
>>
>> NameError in UserController#search
>>
> Like I said before, if you are adhering to the conventions, the class
> name is LineItem, not line_item or Line_item or Line_items
>
> Fred

Sorry the class name is LineItem.
class LineItem < ActiveRecord::Base
belongs_to :order
end
Even then it is throwing the same error.

Abhi Manyu

unread,
Nov 13, 2007, 7:17:45 AM11/13/07
to rubyonra...@googlegroups.com
ok now send me the code and error once more after u updated

Ruchita Sharma

unread,
Nov 13, 2007, 7:24:29 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> ok now send me the code and error once more after u updated

yeah sure.

def search
@orders = Order.find :all
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)
@product << @var
render_text "a"
else
render_text "abc"
end
end
end
end

The error is:

NameError in UserController#search

uninitialized constant UserController::Line_items

RAILS_ROOT: ./script/../config/..
Application Trace | Framework Trace | Full Trace

C:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.4.3/lib/active_support/dependencies.rb:477:in

`const_missing'
C:/rails/herbaltea/app/controllers/user_controller.rb:88:in `search'
C:/rails/herbaltea/app/controllers/user_controller.rb:85:in `each'
C:/rails/herbaltea/app/controllers/user_controller.rb:85:in `search'
C:/rails/herbaltea/app/controllers/user_controller.rb:84:in `each'
C:/rails/herbaltea/app/controllers/user_controller.rb:84:in `search'

--
Posted via http://www.ruby-forum.com/.

Abhi Manyu

unread,
Nov 13, 2007, 7:27:08 AM11/13/07
to rubyonra...@googlegroups.com
Hey you haven't changed
@var = Line_items.find_by_order_id(@id)

Ruchita Sharma

unread,
Nov 13, 2007, 7:30:30 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> Hey you haven't changed
> @var = Line_items.find_by_order_id(@id)

I hve changed it.

Abhi Manyu

unread,
Nov 13, 2007, 7:31:32 AM11/13/07
to rubyonra...@googlegroups.com
what about the error now is it there?

Ruchita Sharma

unread,
Nov 13, 2007, 7:31:55 AM11/13/07
to rubyonra...@googlegroups.com
Ruchita Sharma wrote:
> Abhi Manyu wrote:
>> Hey you haven't changed
>> @var = Line_items.find_by_order_id(@id)
>
> I hve changed it.

Giving the same error.... it is giving this error coz there is no
association between users table and lineitems table. Is there any
solution for that?

Frederick Cheung

unread,
Nov 13, 2007, 7:33:26 AM11/13/07
to rubyonra...@googlegroups.com

On 13 Nov 2007, at 12:31, Ruchita Sharma wrote:

>
> Ruchita Sharma wrote:
>> Abhi Manyu wrote:
>>> Hey you haven't changed
>>> @var = Line_items.find_by_order_id(@id)
>>
>> I hve changed it.
>
> Giving the same error.... it is giving this error coz there is no
> association between users table and lineitems table. Is there any
> solution for that?

Yes. create the association.

Fred

Ruchita Sharma

unread,
Nov 13, 2007, 7:33:37 AM11/13/07
to rubyonra...@googlegroups.com

Ruchita Sharma

unread,
Nov 13, 2007, 7:36:29 AM11/13/07
to rubyonra...@googlegroups.com

But how? I dont have a user_id in lineitems table.

Frederick Cheung

unread,
Nov 13, 2007, 7:39:28 AM11/13/07
to rubyonra...@googlegroups.com

On 13 Nov 2007, at 12:36, Ruchita Sharma wrote:

>
> Frederick Cheung wrote:
>> On 13 Nov 2007, at 12:31, Ruchita Sharma wrote:
>>
>>> solution for that?
>> Yes. create the association.
>>
>> Fred
>
> But how? I dont have a user_id in lineitems table.

Read up on has_many :through

Fred

Abhi Manyu

unread,
Nov 13, 2007, 7:40:38 AM11/13/07
to rubyonra...@googlegroups.com
No not needed
can you plese check whether the values are coming correct. Also try
running by deleting one by one
eg firt delete @var = Line_items.find_by_order_id(@id)
@product << @var
and run check if there is error

Ruchita Sharma

unread,
Nov 13, 2007, 7:46:32 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> No not needed
> can you plese check whether the values are coming correct. Also try
> running by deleting one by one
> eg firt delete @var = Line_items.find_by_order_id(@id)
> @product << @var
> and run check if there is error

The code is:

@orders = Order.find :all
@lineitems = Lineitem.find :all


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 = @lineitems.find_by_order_id(@id)


@product << @var
render_text "a"
else
render_text "abc"

Now the error is:
undefined method `find_by_order_id' for #<Array:0x470c9a8>

Abhi Manyu

unread,
Nov 13, 2007, 7:52:49 AM11/13/07
to rubyonra...@googlegroups.com
you have to give like
@var = LineItem.find_by_order_id(@id)

Abhi Manyu

unread,
Nov 13, 2007, 7:59:09 AM11/13/07
to rubyonra...@googlegroups.com
@orders = Order.find :all
@lineitems = Lineitem.find :all
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 = @lineitems.find_by_order_id(@id)
breakpoint @var

@product << @var
render_text "a"
else
render_text "abc"

Give breakpoint like this and check bvalue of @var also before that
replace
@product=Array.new with @product=Array.new()

Ruchita Sharma

unread,
Nov 13, 2007, 7:54:49 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> you have to give like
> @var = LineItem.find_by_order_id(@id)

Yeah i have given it. But now the value of product is coming #.

Ruchita Sharma

unread,
Nov 13, 2007, 8:11:07 AM11/13/07
to rubyonra...@googlegroups.com

Hi,

I have checked the values. Value of @id=order.id.... here the value of
id is coming right. I have checked the log file as well. @var =
@lineitems.find_by_order_id(@id).... the query is also coming right in
log file. . i.e.SELECT * FROM lineitems WHERE (lineitems.`order_id` =
1),but again the value of @var is coming #

Abhi Manyu

unread,
Nov 13, 2007, 8:16:58 AM11/13/07
to rubyonra...@googlegroups.com
did you check the table entries?

Ruchita Sharma

unread,
Nov 13, 2007, 8:18:24 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> did you check the table entries?

yes i did check the entries.

Abhi Manyu

unread,
Nov 13, 2007, 8:24:21 AM11/13/07
to rubyonra...@googlegroups.com
let me confirm once again
1)you changed @var = @lineitems.find_by_order_id(@id) to
@var = LineItem.find_by_order_id(@id)
2)there is a field in LineItem called order_id
3)the association between LineItem and Order is clearly defined
rt?
if yes
Give
breakpoint LineItem.find_by_order_id(@id)
and tell

Abhi Manyu

unread,
Nov 13, 2007, 8:26:36 AM11/13/07
to rubyonra...@googlegroups.com
I am not getting what

session[:query] = params[:query].strip if params[:query]
if session[:query] and request.xhr?
is as I havent used such code any way I assume it as correct one

Ruchita Sharma

unread,
Nov 13, 2007, 8:29:26 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> I am not getting what
> session[:query] = params[:query].strip if params[:query]
> if session[:query] and request.xhr?
> is as I havent used such code any way I assume it as correct one

I have implemented the textbox to search the user by user name and then
displaying the products as per user id. So this code is to search the
user.

Abhi Manyu

unread,
Nov 13, 2007, 8:31:53 AM11/13/07
to rubyonra...@googlegroups.com
one min user name is unique? or not?

Ruchita Sharma

unread,
Nov 13, 2007, 8:36:36 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> one min user name is unique? or not?

please check this code.... am not able to find why its not working.

@orders = Order.find :all
@lineitems = Lineitem.find :all

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
#@product = @users.collect {|u|
u.orders.collect(&:line_items)}.flatten
@product=Array.new()


@users.each do |user|
@orders.each do |order|
if user.id == order.user_id
@id = order.id

breakpoint Lineitem.find_by_order_id(@id)
#@var = Lineitem.find_by_order_id(@id)
#breakpoint @var
@product << @var
render_text @product
else
render_text "andnddjhg"

Abhi Manyu

unread,
Nov 13, 2007, 8:39:11 AM11/13/07
to rubyonra...@googlegroups.com
did you check value at breakpoint Lineitem.find_by_order_id(@id)

Ruchita Sharma

unread,
Nov 13, 2007, 8:42:08 AM11/13/07
to rubyonra...@googlegroups.com
Abhi Manyu wrote:
> did you check value at breakpoint Lineitem.find_by_order_id(@id)

whenever i give the breakpoint.... my website get hanged and i am not
able to view the results.


Moreover the user names are not unique.

Abhi Manyu

unread,
Nov 13, 2007, 8:48:07 AM11/13/07
to rubyonra...@googlegroups.com
the website get hang because you have given breakpoint
you can check values from console

let ur project folder's name be product let its location be c:
then in console
give like
c:\product\ruby script breakpointer

then run program and come to console
and you can see the value
then type exit there

Abhi Manyu

unread,
Nov 13, 2007, 8:49:53 AM11/13/07
to rubyonra...@googlegroups.com
check that and let me know I am abt to leave
It is loading more messages.
0 new messages