# PLEASE help me if you can

**URL:** <https://www.ruby-forum.com/t/please-help-me-if-you-can/112052>\
**Category:** Rails\
**Created:** [August 14, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/please-help-me-if-you-can/112052 "2007-08-14T18:25:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![enricoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed655f/32.png) [@enricoeur](https://www.ruby-forum.com/u/enricoeur)\
**Post date:** [August 14, 2007, 6:25pm UTC](https://www.ruby-forum.com/t/please-help-me-if-you-can/112052/1 "2007-08-14T18:25:51Z")

</div>

I’m a beginner, i have created for my web application 2 tables “videos”  
and “category”.

I want to create a controller for display all videos by category, for do  
that i write a Category controlle rwith this ACTION

def index  
@temp = 1  
@video\_pages, @videos = paginate :videos,  
:conditions =\> [‘category\_id = ?’, @temp],  
:per\_page =\> 10,  
:order =\> “videos.created\_at desc”  
end

I want to display the category pages by submit the category id directly  
in the URL ( the link to category page must be similar to ‘/category/1’.  
My problem is that when i submit the category id in this way, the  
Category controller return an error message:

Uknown Action

i tried to reassign the category id in this way:

@temp = params[:id]

but don’t work in any way

Thanks in advance

---

<div class="post-metadata">

**Author:** ![enricoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed655f/32.png) [@enricoeur](https://www.ruby-forum.com/u/enricoeur)\
**Post date:** [August 14, 2007, 6:28pm UTC](https://www.ruby-forum.com/t/please-help-me-if-you-can/112052/2 "2007-08-14T18:28:33Z")

</div>

I tried this code:

> def index  
> @temp = 1  
> @video\_pages, @videos = paginate :videos,  
> :conditions =\> [‘category\_id = ?’, @temp],  
> :per\_page =\> 10,  
> :order =\> “videos.created\_at desc”  
> end

this work good and display all videos in category 1

but this:

class CategoryController \< ApplicationController

def index  
@temp = params[:id]  
@video\_pages, @videos = paginate :videos,  
:conditions =\> [‘category\_id = ?’, @temp],  
:per\_page =\> 10,  
:order =\> “videos.created\_at desc”  
end

don’t work

---

<div class="post-metadata">

**Author:** ![enricoeur](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/e/ed655f/32.png) [@enricoeur](https://www.ruby-forum.com/u/enricoeur)\
**Post date:** [August 14, 2007, 6:38pm UTC](https://www.ruby-forum.com/t/please-help-me-if-you-can/112052/3 "2007-08-14T18:38:25Z")

</div>

Hi,

I think this has to do with the fact that your URL format is incorrect,  
so rails is think that you are calling the function titled ‘1’ and so  
never passing the ID to the function index to be stored in the @temp  
variable. This is not what you want ? Try calling it through the browser  
using /catergory/index/1. This should correctly break up the URL using  
the format /[controller name]/[method to invoke]/parameters.

I hope this helps.

Dexter

Enrico Ee wrote:

> I tried this code:
> 
> > def index  
> > @temp = 1  
> > @video\_pages, @videos = paginate :videos,  
> > :conditions =\> [‘category\_id = ?’, @temp],  
> > :per\_page =\> 10,  
> > :order =\> “videos.created\_at desc”  
> > end
> 
> this work good and display all videos in category 1
> 
> but this:
> 
> class CategoryController \< ApplicationController
> 
> def index  
> @temp = params[:id]  
> @video\_pages, @videos = paginate :videos,  
> :conditions =\> [‘category\_id = ?’, @temp],  
> :per\_page =\> 10,  
> :order =\> “videos.created\_at desc”  
> end
> 
> don’t work
