views:

21

answers:

1

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 shorter?

thanks

A: 

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.

jdl