# \[noob question\] View error, Resource route

**URL:** <https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945>\
**Category:** Rails\
**Created:** [April 20, 2009, 9:07am UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945 "2009-04-20T09:07:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [April 20, 2009, 9:07am UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945/1 "2009-04-20T09:07:24Z")

</div>

Hello everyone,

I have a little problem, since I have change my route from resources to  
resource. My files look like:

# config/routes.rb

ActionController::Routing::Routes.draw do |map|  
map.resource :system  
end

# app/controllers/systems\_controller.rb

class SystemsController \< ApplicationController  
def new  
@system = System.new  
end  
end

# app/views/systems/new.html.erb

\<% form\_for @system do |f| %\>  
\<%= f.error\_messages %\>

And here is my error message:

NoMethodError in Systems#new

Showing app/views/systems/new.html.erb where line #1 raised:

undefined method `systems\_path’ for #ActionView::Base:0x3459fe0  
Extracted source (around line #1):

1: \<% form\_for @system do |f| %\>  
2: \<%= f.error\_messages %\>  
3:  
4:

  
RAILS\_ROOT: /Users/pulu/Sites/test

Do you think I get an error in new.html.erb?

Thanks

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [April 20, 2009, 10:19am UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945/2 "2009-04-20T10:19:42Z")

</div>

try…  
\<% form\_tag system\_path do %\>

using @system is a shortcut way of writing systems\_path but it looks  
for the plural path - you’ve set yours to a singular resource path

run “rake routes” to see your available paths in the terminal window.

Hope that helps

On Apr 20, 8:07 am, “Paul A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [April 20, 2009, 11:14am UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945/3 "2009-04-20T11:14:20Z")

</div>

Gavin M. wrote:

> try…  
> \<% form\_tag system\_path do %\>

Thanks, Gavin. When I do this, I get an error at the line 2 about:  
\<%= f.error\_messages %\>

To solve it, I had just rewrite this line with:  
\<%= error\_messages %\>

But an other error message is occuring, saying that “error\_messages” is  
not defined (if I remember well).

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [April 20, 2009, 12:18pm UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945/4 "2009-04-20T12:18:13Z")

</div>

Sorry - should have explained:

If you use the form\_tag method then you can’t pass a variable like |f|

you’d have to replace things like  
f.text\_field :your\_field

with

text\_field :system, :your\_field

and use the error\_messages\_for method instead:  
[http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M001662](http://api.rubyonrails.org/classes/ActionView/Helpers/ActiveRecordHelper.html#M001662)

I think you can use form\_for as you did before but write it like:

\<% form\_for :system, :url =\> {:action =\> :create} do |f| %\>

This would be the easiest option but I’m not 100% sure if that works  
with a singular resource.

Would be curious to find out if it does?

On Apr 20, 10:14 am, “Paul A.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![judge](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/j/9de0a6/32.png) [@judge](https://www.ruby-forum.com/u/judge)\
**Post date:** [April 20, 2009, 6:51pm UTC](https://www.ruby-forum.com/t/noob-question-view-error-resource-route/165945/5 "2009-04-20T18:51:57Z")

</div>

Many thanks, Gavin M…

Thanks to your answer, I had making some modifications to gets this:

\<% form\_tag system\_path do %\>  
\<%= error\_messages\_for ‘system’ %\>  
…  
\<%= submit\_tag ‘Create’ %\>  
\<% end %\>

After testing this line:  
\<% form\_for :system, :url =\> {:action =\> :create} do |f| %\>

it’s okay too.
