开发者

How to populate rails 2 select using helpers and conditions

I'm working with a simple select like this:

<%= select(@file, @file.file_id, File.all.collect {|p| [ p.name, p.id ] }) %>

However, I would like to add some conditions to that "all"...

for example

开发者_如何转开发

"id != @file.id"

(I don't want the current file to be shown in the select list).

how can I do that?

Thank you!


Try

File.find(:all, :conditions => ["id != ?", @file.id]).map {|p| [ p.name, p.id ]}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜