开发者

conditions without repeats

Hi i'm using this for getting data:

Topic.find(:all, :include => ...,
:conditions => @core ? ["cores_topics.id = ? AND visible = 1 AND (distance < ? OR cores.id IN (?))",@core.id, @user_location[3].to_i, @user_friends] : 
["visible = 1 AND (distance < ? OR cores.id IN (?))", @user_location[3].to_i, @user_friends], 
...

how can i rewrite the conditions sh开发者_开发问答orter?


how can i rewrite the conditions shorter?

User smaller variable names.

OK, really. Read the docs for named_scope. Your code is crying out for them.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜