:select in find does not work with RESTful routes

Hello all,

I haven't been able to find an answer to this, so I thought the
collective intelligence of this group might be able to help me out.
Basically, I have something close to a blog engine written. Now, I do
realize that this is duplicating work, but my employer wants to do so,
despite my arguments. Here's the issue that I've run into. Maybe this
is a bug in Rails, maybe it's how I'm using it.

I have a text field in the database that I don't want to necessarily
pull in the index action, since it may be large. I've created a
preview field in the same table that holds a truncated value of the
text field. After googling around and reading a few parts of few Rails
books, I've come to the solution like this:

    @posts = @user.posts.find(:all, :select => 'title, preview,
created_at', :conditions => ['draft = ?', false])

As it reads, I want certain columns of the Posts table, scoping
through the current user and I want posts that are not published yet.
This works perfectly, but for one problem. The RESTful routes I've
created in the routes.rb file do not give me proper URLs for the show,
edit and delete actions. Routes are defined like this:

     map.resources :users, :has_many => [:posts, :comments]

Is this a bug in Rails or is it me?

Thanks in advance for any help

Hello all,

I haven't been able to find an answer to this, so I thought the
collective intelligence of this group might be able to help me out.
Basically, I have something close to a blog engine written. Now, I do
realize that this is duplicating work, but my employer wants to do so,
despite my arguments. Here's the issue that I've run into. Maybe this
is a bug in Rails, maybe it's how I'm using it.

I have a text field in the database that I don't want to necessarily
pull in the index action, since it may be large. I've created a
preview field in the same table that holds a truncated value of the
text field. After googling around and reading a few parts of few Rails
books, I've come to the solution like this:

  @posts = @user.posts.find(:all, :select => 'title, preview,
created_at', :conditions => ['draft = ?', false])

You're not selecting the id field, so rails doesn't know the id of the
post objects which will really screw things up.

Fred

Thanks, Fred. That will do it.