开发者

How to populate rails 2 select using helpers and conditions

开发者 https://www.devze.com 2023-04-10 14:25 出处:网络
I\'m working with a simple select like this: <%=select(@file, @file.file_id, File.all.collect {|p| [ p.name, p.id ] }) %>

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

精彩评论

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