bananafishbones
2005-Jan-24 07:47 UTC
how can i override the show view to capture show/n , show/n+1, etc.
Hi - Yet another rails newbie ... I have a simple list view rhtml with data returned from a db and displayed within a table. Each row has a show action link_to based on the id field in the table row. i.e. http://127.0.0.1:3000/myapp/show/1 http://127.0.0.1:3000/myapp/show/2 http://127.0.0.1:3000/myapp/show/3 I want to override the default show view but I don''t understand how I can do this with a single file - in particular I am confused with the urls which are dynamic and based on the list id. How can I create a single show rhtml view that "captures" link_to actions for http://127.0.0.1/myapp/show/n http://127.0.0./show/n+1 etc? I realize this is a very basic question and I''ve probably missed something simple, however I''ve searched the documentation to no avail. Thanks, bananafishbones (still coming up to speed on rails terminology...)
Dale K. Hawkins
2005-Jan-24 14:40 UTC
Re: how can i override the show view to capture show/n , show/n+1, etc.
Why would you want to capture all calls to show? Assuming you have more than one object type to show.... You could define a method in application.rb: class ApplicationController < ActionController::Base def show # define show here render "show" end end Then create app/views/show: This is the show template. <ul> <% @params.each do | k, v | %> <li><%= "#{k}: #{v}" %></li> <% end %> </ul> But, this does not really align with the rails way. Join us. Be happy. -Dale On Mon, 24 Jan 2005 02:47:11 -0500, bananafishbones <banano.fisi.ostos-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hi - > > Yet another rails newbie ... > > I have a simple list view rhtml with data returned from a db and > displayed within a table. Each row has a show action link_to based on > the id field in the table row. > > i.e. > http://127.0.0.1:3000/myapp/show/1 > http://127.0.0.1:3000/myapp/show/2 > http://127.0.0.1:3000/myapp/show/3 > > I want to override the default show view but I don''t understand how I > can do this with a single file - in particular I am confused with the > urls which are dynamic and based on the list id. > > How can I create a single show rhtml view that "captures" link_to > actions for http://127.0.0.1/myapp/show/n http://127.0.0./show/n+1 > etc? > > I realize this is a very basic question and I''ve probably missed > something simple, however I''ve searched the documentation to no avail. > > Thanks, > bananafishbones (still coming up to speed on rails terminology...) > _______________________________________________ > Rails mailing list > Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-- This is my sig. Isn''t it cool....