Hi,
I''m a newbie and I can''t resolve a simple problem. I generated
a
scaffold "course" and now I try to create a new page to edit my data,
because my goal is produce a two different page with two different
views.
My first step is reproduce the new page like the original edit page, so,
in the successive time, modify it.
I create the new page "score.html.erb":
<h1>Editing course</h1>
<%= render ''form'' %>
<%= link_to ''Show'', @course %> |
<%= link_to ''Back'', courses_path %>
I add the method score in "courses_controller.rb"
def score
@course = Course.find(params[:id])
end
and I put in "/courses/index.html.erb" the link:
<td><%= link_to ''Edit'', score_course_path(course)
%></td>
next destroy link.
I receive the error:
NoMethodError in Courses#index
undefined method `score_course_path'' for
#<#<Class:0x347c0a0>:0x3481830>
I try to add some different code line in routes.rb, but this not help
me.
Thanks for the help :)
--
Posted via http://www.ruby-forum.com/.
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Maybe you forgot add resource route? среда, 12 декабря 2012 г., 13:30:59 UTC+4 пользователь Ruby-Forum.com User написал:> > Hi, > > I''m a newbie and I can''t resolve a simple problem. I generated a > scaffold "course" and now I try to create a new page to edit my data, > because my goal is produce a two different page with two different > views. > > My first step is reproduce the new page like the original edit page, so, > in the successive time, modify it. > > I create the new page "score.html.erb": > > <h1>Editing course</h1> > <%= render ''form'' %> > <%= link_to ''Show'', @course %> | > <%= link_to ''Back'', courses_path %> > > I add the method score in "courses_controller.rb" > > def score > @course = Course.find(params[:id]) > end > > and I put in "/courses/index.html.erb" the link: > > <td><%= link_to ''Edit'', score_course_path(course) %></td> > > next destroy link. > > I receive the error: > > NoMethodError in Courses#index > undefined method `score_course_path'' for > #<#<Class:0x347c0a0>:0x3481830> > > I try to add some different code line in routes.rb, but this not help > me. > > Thanks for the help :) > > -- > Posted via http://www.ruby-forum.com/. >-- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msg/rubyonrails-talk/-/vWlW5GH_sLsJ. For more options, visit https://groups.google.com/groups/opt_out.
Alex Korolev wrote in post #1088794:> Maybe you forgot add resource route? > > , 12 2012 ., 13:30:59 UTC+4 Ruby-Forum.com User > :In routes.rb is present: resources :courses and I add/remove: match ''courses/:id/score'' => ''course#score'', :as => :score in many version... but don''t work :( -- Posted via http://www.ruby-forum.com/. -- 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org For more options, visit https://groups.google.com/groups/opt_out.
Ok, this is the solution:
resources :courses do
member do
get ''score''
end
end
Thanks Alex.
--
Posted via http://www.ruby-forum.com/.
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit https://groups.google.com/groups/opt_out.
Do you try this:
resources :courses do
member do
get ''score''
end
end
среда, 12 декабря 2012 г., 14:03:00 UTC+4 пользователь Ruby-Forum.com User
написал:>
> Alex Korolev wrote in post #1088794:
> > Maybe you forgot add resource route?
> >
> > , 12 2012 ., 13:30:59 UTC+4 Ruby-Forum.com User
> > :
>
> In routes.rb is present:
>
> resources :courses
>
> and I add/remove:
>
> match ''courses/:id/score'' =>
''course#score'', :as => :score
>
> in many version... but don''t work :(
>
> --
> Posted via http://www.ruby-forum.com/.
>
--
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk+unsubscribe@googlegroups.com.
To view this discussion on the web visit
https://groups.google.com/d/msg/rubyonrails-talk/-/X8_pcX-eqF4J.
For more options, visit https://groups.google.com/groups/opt_out.