Long arsd problem


This might be really obvious to someone, but this is doing my head in,
however I am a noob so any help would be appreciated.

this is my routes.rb file:
map.resources :comments
map.resources :posts
map.connect :logs

I have two controllers, one is called Posts (which I generated using a
scaffold) and the other is called logs-- I just created a controller for

logs controller:

def index
@logs = (Post.all)

def show
@log = Post.find(params[:id])

Now my problem is this:

index.html in logs folder:

<%= link_to 'read more...', log%>

I want this to link to link to log/:id (e.g. logs/1) when they click on
the first post, however it keeps going to posts/:id (e.g. posts/1)

Sorry about the long question, I’m trying to give as much information as
possible, any help would be appreciated.


Hey John,

Rails figures out that your ‘log’ object in your view is, in truth, a
object. As such the url it generates is equivalent to post_path(log).

You’ll want to edit your index template as follows:

<%= link_to 'read more...', log_path(log) %>

Gustav P.

On Sat, Jul 18, 2009 at 1:46 AM, John M. <

Thank you very very much!