-6
我想用ActiveRecord的方法在不同的地方 例如Rails的ActiveRecord的方法在不同的地方
if ..something..
Post.where(..something..)
else
Post.where(..something..)
end
@posts = Post.all(:order => ..something..)
,這怎麼可能? 感謝
我想用ActiveRecord的方法在不同的地方 例如Rails的ActiveRecord的方法在不同的地方
if ..something..
Post.where(..something..)
else
Post.where(..something..)
end
@posts = Post.all(:order => ..something..)
,這怎麼可能? 感謝
你可以做這樣的事情:
if ..something..
@posts = Post.where(..something..)
else
@posts = Post.where(..something..)
end
@posts = @posts.all(:order => ..something..)
這是更好地做到這一點,在Rails 3中:
@posts = @posts.order(..something..)
我只是不想使用chaning。我想分裂他們 – 2012-07-25 12:09:12
我不明白你的問題。您想做什麼? – iblue 2012-07-25 11:36:21
什麼是東西?什麼?我什麼都不懂...... – Salil 2012-07-25 11:44:45
@iblue我只是不想使用鏈式方法。我想在不同的地方將它們分開 – 2012-07-25 11:52:56