SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    RoR - Link_to and routes

    I am really struggling to get a link_to link working in my view. I want to link to a controller and an action with two variables. This has a route set up as below:

    Code:
    map.show_all_news 'article/showall/:month/:year', :controller => '/article', :action => 'showall', :month => /\d{1,2}/, :year => /\d{4}/
    The route seems to work okay as when I type in localhost:3000/article/showall/04/2009 it works and displays the correct content etc.

    However I can't get the link_to working in the view to display links to it. I've followed various instructions on the web but can't seem to get it solved.

    I've got this in my view at the moment for the link_to

    Code:
    <%= link_to 'April 2009', show_all_news_path(:month => 04, :year => 2009) %>

  2. #2
    SitePoint Evangelist
    Join Date
    Feb 2006
    Location
    Worcs. UK
    Posts
    404
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Try
    Code:
    <&#37;= link_to 'April 2009', show_all_news_url(:month => 04, :year => 2009) %>

  3. #3
    SitePoint Enthusiast
    Join Date
    Jan 2008
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Cheers, will have a go and let you know how I get on.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •