> Hello list,
>
Hi Mark,
> I'm a fairly nooby Rails developer of very little brain, and this error has
> had me confused for the last several hours.
>
> It's a very simple (unfinished) Rails app. It has a model called Tasks. It
> has a very basic routes.rb
>
> resources :tasks
> root :to => 'tasks#index'
>
> A vanilla controller (create action not properly defined yet because that
> would have been next on the list when I ran into this problem)
>
> class TasksController < ApplicationController
>
> def index
> @tasks = Tasks.all
> end
>
> def new
> @task = Tasks.new
> end
>
> def create
> end
>
> end
models are always singular in rails. Try the following:
def index
@tasks = Task.all
end
def new
@task = Task.new
end
That should help.
Regards, Max.
> And a view for the /tasks/new action
>
> <h1>Create new task</h1>
> <%= form_for @task do |form| %>
> <%= lots of form. blah blah here... %>
> <% end %>
>
> And when the view is rendered I get the following error:
>
> undefined method `tasks_index_path' for
> #<#<Class:0x000000020c04e8>:0x000000020b74d8>
>
> Extracted source (around line *#2*):
>
> 1: <h1>Create new task</h1>
> 2: <%= form_for @task do |form| %>
>
> And here are the top few lines of the stack trace:
>
> actionpack (3.0.0)
> lib/action_dispatch/routing/polymorphic_routes.rb:114:in
> `polymorphic_url'
> actionpack (3.0.0)
> lib/action_dispatch/routing/polymorphic_routes.rb:120:in
> `polymorphic_path'
> actionpack (3.0.0) lib/action_view/helpers/form_helper.rb:335:in
> `apply_form_for_options!'
> actionpack (3.0.0) lib/action_view/helpers/form_helper.rb:307:in `form_for'
> app/views/tasks/new.html.erb:2:in
> `_app_views_tasks_new_html_erb__194514136627382544_17145340__4434388515179536201'
>
> I don't really understand where "tasks_index_path" came from or why form_for
> has bombed out so spectacularly, especially given how simple the code is
> right now. Can anyone point me at what I might be doing wrong?
>
> Oh yes, it's rails 3.0.0 on ruby 1.9.2 running on Ubuntu 10.04.
>
> Thanks,
>
> Mark
>
--
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en.