# Problems after scaffold

**URL:** <https://www.ruby-forum.com/t/problems-after-scaffold/145350>\
**Category:** Rails\
**Created:** [August 8, 2008, 10:24am UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350 "2008-08-08T10:24:10Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [August 8, 2008, 10:24am UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350/1 "2008-08-08T10:24:10Z")

</div>

Please some help!!!  
I made a scaffold the search, then i added a new method called  
printimages  
in the search controller and a view for the same but then i want to  
access  
throw the browser to this method searchs/printimages  
and it throws me that cant find the id. Somebody knows what is the  
problem?  
the same happends when i do a link\_to :action the name of the method in  
the  
controller.

## Thank you!

Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [August 8, 2008, 12:00pm UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350/2 "2008-08-08T12:00:51Z")

</div>

On Fri, Aug 8, 2008 at 3:45 AM, Felipe V. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> Please some help!!!  
> I made a scaffold the search, then i added a new method called printimages  
> in the search controller and a view for the same but then i want to access  
> throw the browser to this method searchs/printimages  
> and it throws me that cant find the id. Somebody knows what is the problem?  
> the same happends when i do a link\_to :action the name of the method in the  
> controller.

Can you show the code for printimages and the link in the  
view that points to it?

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [August 8, 2008, 1:45pm UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350/3 "2008-08-08T13:45:13Z")

</div>

What version of rails are you using? If you are using 2.0 or later  
then the scaffold command created a RESTful controller for you. That  
controller is “prewired” to recognize index, show, edit, update, new,  
create, and destroy. For actions with other names you’ll have to  
modify routes.rb.

The modification to make in routes.rb will depend on what the  
printimages action needs to do. The controller (search) sounds like  
it is responsible for managing many different kinds of objects rather  
than one particular object so you probably want to add ‘printimages’  
as a collection option (ie., it requires no id). That would look  
something like this in your routes.rb

map.resources :search, :collection=\>{:printimages=\>:put}

When you specify a collection action (or a :member action when you  
have one particular object in mind) you provide a hash whose keys are  
the names of the actions and whose values are the HTTP verbs that are  
permitted to access that action. If you specify anything other  
than :get or :post you will have to do a little extra work when  
specifying the url for a link.

Check out the ActionController::Resources api for more info.

HTH,  
AndyV

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [August 8, 2008, 3:30pm UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350/4 "2008-08-08T15:30:45Z")

</div>

## I will try that thank you very much!

Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC

---

<div class="post-metadata">

**Author:** ![pipex](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/f6c823/32.png) [@pipex](https://www.ruby-forum.com/u/pipex)\
**Post date:** [August 8, 2008, 3:46pm UTC](https://www.ruby-forum.com/t/problems-after-scaffold/145350/5 "2008-08-08T15:46:33Z")

</div>

It worked thankyou very much!!!

–  
Felipe V. Contesse  
IngenierÃ­a Civil Industrial UC
