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.
精彩评论