Jimmy Perrine
2009-Feb-28 19:33 UTC
Linking to an external model/view within an application
Hey guys, I am working on a class project and I have two scaffolded models, articles and sub_articles. I have the relationships set to articles having many sub_articles and sub_articles belonging to articles, which is also stated in the routes file. I am trying to display a link to each sub article when viewing a specific article, as it stands now I can display the link with the sub article title but it links back to the same article. here are some code samples: this is my sub article partial that shows the links, <li><%= link_to (sub_article.title), h(sub_article.id) %></li> how do i add the prefix sub_articles/ to the id link? also when I go to a url like /sub_articles/1 I get an unknown action error, but I have a show.html.erb file your help would be greatly appreciated, thank you all. -- 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 -~----------~----~----~----~------~----~------~--~---
link_to(sub_article.title, sub_article) Rails knows the rest. -eric On Feb 28, 11:33 am, Jimmy Perrine <rails-mailing-l...-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org> wrote:> Hey guys, > > I am working on a class project and I have two scaffolded models, > articles and sub_articles. I have the relationships set to articles > having many sub_articles and sub_articles belonging to articles, which > is also stated in the routes file. > > I am trying to display a link to each sub article when viewing a > specific article, as it stands now I can display the link with the sub > article title but it links back to the same article. > > here are some code samples: > > this is my sub article partial that shows the links, > > <li><%= link_to (sub_article.title), h(sub_article.id) %></li> > > how do i add the prefix sub_articles/ to the id link? > > also when I go to a url like /sub_articles/1 I get an unknown action > error, but I have a show.html.erb file > > your help would be greatly appreciated, thank you all. > -- > 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@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Jimmy Perrine
2009-Feb-28 20:23 UTC
Re: Linking to an external model/view within an application
but that ends up with a link that looks like this in the browser http://localhost:3000/articles/1#%3CSubArticle:0x597e8c0%3E do i need to add something else where to make this 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-/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 -~----------~----~----~----~------~----~------~--~---