I have a basic blog with images - and in the index.rhtml view file I have the following: <ul> <% @contents.each do |content| -%> <li><%= content.title %></li> <li><%= content.summary %></li> <li> <%= link_to image_tag(content.image.public_filename(:thumb)), content, :action => ''show'', :id => content %> </li> <li><%= link_to content, :action => ''show'', :id => content %></li> <% end -%> </ul> As soon as I add a name for the link - e.g. <%= link_to ''view content detail'', content, :action => ''show'', :id => content %> the link no longer goes to the correct detail page - instead just goes back to "index". (the same applies to the link_to from the image) Without the ''view article detail'' inserted - the ''#'' links correctly url = contents/1 .... contents/2 ....etc etc just in case.... (routes.rb = map.resources :contents) What am I missing here? Thanks in advance (and yes (previous post), I am still struggling with the IE7 CSS problem!!) -- 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 -~----------~----~----~----~------~----~------~--~---
On Feb 13, 1:17 pm, Liam 11 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> I have a basic blog with images - and in the index.rhtml view file I > have the following:[...] I''m certainly no expert, but so far I''ve found that editing view/foo/ show.rhtml achieves the purposes I need. I''m curious about why you''re editing index.rhtml -- what does that accomplish? -Thufir --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Feb 13, 9:17 pm, Liam 11 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> As soon as I add a name for the link - e.g. > > <%= link_to ''view content detail'', content, :action => ''show'', :id => > content %>Does removing the first content variable from your link help? The link_to helper normally takes the form of <%= link_to "Link Text Here", url_here %> Also, as you''re using RESTful routes, you can rewrite your link as: <%= link_to "View link details", content_url(content) %> Robin --~--~---------~--~----~------------~-------~--~----~ 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
I''d strongly recommend using the link_to format that Robin recommended. As for your specific problem, check the development log. What kind of http req are you getting, GET or POST? My suspicion is that you''re getting a post which Rails interprets as an insert into the collection (probably creating a lot of empty records at this point!) and then you''re being redirected back to the index after the insert. With Robin''s method you can be sure of the http request by: <%= link_to "View link details", content_url(content, :method=>:get) %> On Feb 14, 8:08 am, Robin Fisher <robinjfis...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On Feb 13, 9:17 pm, Liam 11 <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote: > > > As soon as I add a name for the link - e.g. > > > <%= link_to ''view content detail'', content, :action => ''show'', :id => > > content %> > > Does removing the first content variable from your link help? > > The link_to helper normally takes the form of <%= link_to "Link Text > Here", url_here %> Also, as you''re using RESTful routes, you can > rewrite your link as: > > <%= link_to "View link details", content_url(content) %> > > Robin--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
AndyV wrote:> I''d strongly recommend using the link_to format that Robin > recommended. As for your specific problem, check the development > log. What kind of http req are you getting, GET or POST? My > suspicion is that you''re getting a post which Rails interprets as an > insert into the collection (probably creating a lot of empty records > at this point!) and then you''re being redirected back to the index > after the insert. > > With Robin''s method you can be sure of the http request by: > > <%= link_to "View link details", content_url(content, :method=>:get) > %>Fantastic - thanks to all - everything works perfectly now -- 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 -~----------~----~----~----~------~----~------~--~---