hi @ all I create a new archiv.html.erb and a archiv method in the controller. Now, I would like to link from index.html.erb to archiv.html.erb. I tried to use <%= link_to ''archive'', archiv_xxx_path %> but it doesn''t run. It appears a error message "SyntaxError in xxx#index". Does anyone know, how I can enhance this problem? thanks a lot... -- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Hi, You can use <%= link_to ''archive'', :action => ''archive'' %> in the view. Then define an action in your controller. To do this, all you need is: def archive end This will automatically go to a page titled "archive" in your controller''s view, ex: archive.rhtml Good luck, - Jeff K. R. wrote:> hi @ all > > I create a new archiv.html.erb and a archiv method in the controller. > Now, I would like to link from index.html.erb to archiv.html.erb. I > tried to use <%= link_to ''archive'', archiv_xxx_path %> but it doesn''t > run. > It appears a error message "SyntaxError in xxx#index". > > Does anyone know, how I can enhance this problem? > > thanks a lot...-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''ve do this but it appears the error: "ActiveRecord::RecordNotFound in xxxController#show Couldn''t find xxx with ID=archiv " It seems like a routing problem, isn''t it? Jeff Miller wrote:> Hi, > You can use <%= link_to ''archive'', :action => ''archive'' %> in the view. > > Then define an action in your controller. To do this, all you need is: > def archive > end > This will automatically go to a page titled "archive" in your > controller''s view, ex: archive.rhtml > > Good luck, > - Jeff-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
That I''m not so sure on... Is your action defined in a different controller? If so, you can use: <%= link_to ''action'', :controller => ''ControllerName'', :action => ''ActionName'' %> Hope it helps... Other than that, I don''t know what that error is... K. R. wrote:> I''ve do this but it appears the error: > "ActiveRecord::RecordNotFound in xxxController#show > Couldn''t find xxx with ID=archiv " > > It seems like a routing problem, isn''t it? > > > > Jeff Miller wrote: >> Hi, >> You can use <%= link_to ''archive'', :action => ''archive'' %> in the view. >> >> Then define an action in your controller. To do this, all you need is: >> def archive >> end >> This will automatically go to a page titled "archive" in your >> controller''s view, ex: archive.rhtml >> >> Good luck, >> - Jeff-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
No, both methods are in the same controller - so I don''t need the :controller statement. In the new version of rails (2.0), I can use for example <%= link_to ''show'', show_xxx_path %>. Why can''t I use the same principle with the archive? I want to use <%= link_to ''archive'', archiv_xxx_path %> but it doesn''t run! Jeff Miller wrote:> That I''m not so sure on... Is your action defined in a different > controller? If so, you can use: > <%= link_to ''action'', :controller => ''ControllerName'', :action => > ''ActionName'' %> > > Hope it helps... Other than that, I don''t know what that error is...-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
hmmm... I''m pretty new at RoR, so I''m not sure about this, but have you tried naming it something other than "archive"? Perhaps it is a built-in method or class or something that is throwing off your statement. Try "archive_data" or something. K. R. wrote:> No, both methods are in the same controller - so I don''t need the > :controller statement. > > In the new version of rails (2.0), I can use for example <%= link_to > ''show'', show_xxx_path %>. Why can''t I use the same principle with the > archive? I want to use <%= link_to ''archive'', archiv_xxx_path %> but it > doesn''t run! > > > Jeff Miller wrote: >> That I''m not so sure on... Is your action defined in a different >> controller? If so, you can use: >> <%= link_to ''action'', :controller => ''ControllerName'', :action => >> ''ActionName'' %> >> >> Hope it helps... Other than that, I don''t know what that error is...-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
sorry, but it isn''t a problem with the naming convention. When I put an id behind the url, then the application runs. For example: http://localhost:3000/xxx/archive/1 but with http://localhost:3000/xxx/archive it appears a error message. So I must change the routes.rb but I don''t know how... Now when I use http://localhost:3000/xxx/archive the interpreter means, that archive is an id and not a method. Jeff Miller wrote:> hmmm... I''m pretty new at RoR, so I''m not sure about this, but have you > tried naming it something other than "archive"? Perhaps it is a built-in > method or class or something that is throwing off your statement. Try > "archive_data" or something.-- 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
akbar.ibrahim-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
2008-Jan-18 21:05 UTC
Re: link_to problem
Hi K. R., The record not found error is due to the RESTful interpretation of URLs by Rails. Given the URL ... http://localhost:3000/xxx/archive ... Rails rails assumes that you are calling the ''show'' action on the ''xxx'' controller with ''archiv'' as the ID of the model instance to be shown. To get rails to understand that ''archiv'' is a new action, you need to edit the routes.rb file and add appropriate routes using either the :collection option (if the archiv action works with a collection of model instances) or with the :member option (if you are working with only one instance of the model). Check out the screencasts below for a quick intro to routes and custom actions Named routes http://railscasts.com/episodes/34 Custom REST actions http://railscasts.com/episodes/35 Cheers, Akbar On Jan 18, 3:29 pm, "K. R." <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> sorry, but it isn''t a problem with the naming convention. When I put an > id behind the url, then the application runs. For example:http://localhost:3000/xxx/archive/1but withhttp://localhost:3000/xxx/archiveit appears a error message. So I must > change the routes.rb but I don''t know how... > Now when I usehttp://localhost:3000/xxx/archivethe interpreter means, > that archive is an id and not a method. > > Jeff Miller wrote: > > hmmm... I''m pretty new at RoR, so I''m not sure about this, but have you > > tried naming it something other than "archive"? Perhaps it is a built-in > > method or class or something that is throwing off your statement. Try > > "archive_data" or something. > > -- > Posted viahttp://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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
You need to specify that your resource have a new method, i.e : map.resources user do |users| user.resources :tournament, :member=>{:stats=>:get } end And now you can request the url "/users/:user_id/tournaments/:tournament_id/stats" with stats_user_tournament(@user, @tournament) 2008/1/18, K. R. <rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>:> > hi @ all > > I create a new archiv.html.erb and a archiv method in the controller. > Now, I would like to link from index.html.erb to archiv.html.erb. I > tried to use <%= link_to ''archive'', archiv_xxx_path %> but it doesn''t > run. > It appears a error message "SyntaxError in xxx#index". > > Does anyone know, how I can enhance this problem? > > thanks a lot... > -- > Posted via http://www.ruby-forum.com/. > > > >-- ------------------------------------- Pedro Del Gallego Email : pedro.delgallego-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---