Replace deprecated finder methods
This commit is contained in:
parent
d8399d3e18
commit
6c51b3cc0a
7 changed files with 32 additions and 19 deletions
|
@ -151,9 +151,9 @@ class ApiController < ApplicationController
|
|||
# find which ways are needed
|
||||
ways = Array.new
|
||||
if node_ids.length > 0
|
||||
way_nodes = WayNode.find_all_by_node_id(node_ids)
|
||||
way_nodes = WayNode.where(:node_id => node_ids)
|
||||
way_ids = way_nodes.collect { |way_node| way_node.id[0] }
|
||||
ways = Way.find(way_ids, :include => [:way_nodes, :way_tags])
|
||||
ways = Way.preload(:way_nodes, :way_tags).find(way_ids)
|
||||
|
||||
list_of_way_nodes = ways.collect { |way|
|
||||
way.way_nodes.collect { |way_node| way_node.node_id }
|
||||
|
|
|
@ -27,7 +27,7 @@ class BrowseController < ApplicationController
|
|||
|
||||
def way
|
||||
@type = "way"
|
||||
@way = Way.find(params[:id], :include => [:way_tags, {:changeset => :user}, {:nodes => [:node_tags, {:ways => :way_tags}]}, :containing_relation_members])
|
||||
@way = Way.preload(:way_tags, :containing_relation_members, :changeset => :user, :nodes => [:node_tags, :ways => :way_tags]).find(params[:id])
|
||||
@next = Way.visible.where("id > ?", @way.id).order("id ASC").first
|
||||
@prev = Way.visible.where("id < ?", @way.id).order("id DESC").first
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
|
@ -36,7 +36,7 @@ class BrowseController < ApplicationController
|
|||
|
||||
def way_history
|
||||
@type = "way"
|
||||
@way = Way.find(params[:id], :include => [:way_tags, {:old_ways => {:changeset => :user}}])
|
||||
@way = Way.preload(:way_tags, :old_ways => { :changeset => :user }).find(params[:id])
|
||||
rescue ActiveRecord::RecordNotFound
|
||||
render :action => "not_found", :status => :not_found
|
||||
end
|
||||
|
|
|
@ -279,7 +279,7 @@ class NotesController < ApplicationController
|
|||
@description = t 'note.mine.subheading', :user => render_to_string(:partial => "user", :object => @this_user)
|
||||
@page = (params[:page] || 1).to_i
|
||||
@page_size = 10
|
||||
@notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).all
|
||||
@notes = @this_user.notes.order("updated_at DESC, id").uniq.offset((@page - 1) * @page_size).limit(@page_size).preload(:comments => :author).to_a
|
||||
else
|
||||
@title = t 'user.no_such_user.title'
|
||||
@not_found_user = params[:display_name]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue