This makes the queries shorter and easier to read.
raise OSM::APINotFoundError if current_user.nil? || current_user != u
end
- changesets.where(:user_id => u.id)
+ changesets.where(:user => u)
end
end
end
# Find the comments we want to return
- @comments = NoteComment.where(:note_id => notes).order("created_at DESC").limit(result_limit).preload(:note)
+ @comments = NoteComment.where(:note => notes).order("created_at DESC").limit(result_limit).preload(:note)
# Render the result
respond_to do |format|
if @params[:display_name]
changesets = if user.data_public? || user == current_user
- changesets.where(:user_id => user.id)
+ changesets.where(:user => user)
else
changesets.where("false")
end
elsif @params[:bbox]
changesets = conditions_bbox(changesets, BoundingBox.from_bbox_params(params))
elsif @params[:friends] && current_user
- changesets = changesets.where(:user_id => current_user.friends.identifiable)
+ changesets = changesets.where(:user => current_user.friends.identifiable)
elsif @params[:nearby] && current_user
- changesets = changesets.where(:user_id => current_user.nearby)
+ changesets = changesets.where(:user => current_user.nearby)
end
changesets = changesets.where("changesets.id <= ?", @params[:max_id]) if @params[:max_id]
elsif params[:friends]
if current_user
@title = t ".title_friends"
- entries = DiaryEntry.where(:user_id => current_user.friends)
+ entries = DiaryEntry.where(:user => current_user.friends)
else
require_user
return
elsif params[:nearby]
if current_user
@title = t ".title_nearby"
- entries = DiaryEntry.where(:user_id => current_user.nearby)
+ entries = DiaryEntry.where(:user => current_user.nearby)
else
require_user
return
if params[:search_by_user].present?
@find_user = User.find_by(:display_name => params[:search_by_user])
if @find_user
- @issues = @issues.where(:reported_user_id => @find_user.id)
+ @issues = @issues.where(:reported_user => @find_user)
else
@issues = @issues.none
flash.now[:warning] = t(".user_not_found")
if current_user == @user && @role == "administrator"
flash[:error] = t("user_role.filter.not_revoke_admin_current_user")
else
- UserRole.where(:user_id => @user.id, :role => @role).delete_all
+ UserRole.where(:user => @user, :role => @role).delete_all
end
redirect_to user_path(@user)
end
save!
tags = self.tags
- ChangesetTag.where(:changeset_id => id).delete_all
+ ChangesetTag.where(:changeset => id).delete_all
tags.each do |k, v|
tag = ChangesetTag.new
assert_response :success
assert_template :new
- assert_nil UserPreference.where(:user_id => user.id, :k => "diary.default_language").first
+ assert_nil UserPreference.where(:user => user, :k => "diary.default_language").first
end
def test_create
# checks if user was subscribed
assert_equal 1, entry.subscribers.length
- assert_equal "en", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v
+ assert_equal "en", UserPreference.where(:user => user, :k => "diary.default_language").first.v
end
def test_create_german
# checks if user was subscribed
assert_equal 1, entry.subscribers.length
- assert_equal "de", UserPreference.where(:user_id => user.id, :k => "diary.default_language").first.v
+ assert_equal "de", UserPreference.where(:user => user, :k => "diary.default_language").first.v
end
def test_new_spammy