Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save aya-soft/0efe89811d05fa90bb85c571e9eae01c to your computer and use it in GitHub Desktop.
Save aya-soft/0efe89811d05fa90bb85c571e9eae01c to your computer and use it in GitHub Desktop.
Контроллеры в пространстве имен Profile предназначены для работы с данными конкретных пользователей!Как же ты тут выбираешь из базы все комменты без разбора?
class Profile::ServiceStationCommentsController < ApplicationController
before_filter :authenticate_user!
before_filter :load_spare, only: [:index, :new]
def index
@comments = ServiceStationComment.all
end
@aya-soft
Copy link
Author

aya-soft commented May 27, 2016

Сравни например:

class Profile::DeliveryInquiriesController < ApplicationController

  before_filter :authenticate_user!

  before_filter :load_model, only: [:edit, :update, :show, :order, :copy]

  def index
    @filter_number = params[:filter].try(:[], :number)
    @filter_date = params[:filter].try(:[], :date)
    @filter_keywords = params[:filter].try(:[], :keywords)
    @delivery_inquiries = current_user.client.delivery_inquiries.filtered_by(params[:filter]).order("created_at desc").paginate(page: params[:page], per_page: 10)
  end

ВИДИШЬ??? запросы конкретного клиента!

@delivery_inquiries = current_user.client.delivery_inquiries.filtered_by(params[:filter]).order("created_at desc").paginate(page: params[:page], per_page: 10)

@romhi
Copy link

romhi commented May 30, 2016

У меня список своих комментариев пользователь видит на странице своего сервисного центра service_station index. Внизу в табличке. Я удалил этот экшн чтобы не путаться

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment