0

ユーザーがログインした直後に別のホームページにリダイレクトできるようにしたいのですが (この部分は機能しています)、ログインしたユーザーが必要に応じてインデックス フィードにアクセスできるようにしたいと考えています。現時点では、favorites_show_path のみが表示され、@guidelines = Guideline.order(:title).all は表示されません。ログイン後にホーム ページを取得して favourites_show_path に直接移動する方法はありますが、@guidelines = Guideline.order(:title).all を表示することはできますか?

 def index
    if params[:search].present?
    @search = Sunspot.search(Guideline) do  
      fulltext params[:search]
    end
    @guidelines = @search.results
  else
    redirect_to favourites_show_path, :action => 'index' and return if current_user
    @guidelines = Guideline.order(:title).all
  end
4

2 に答える 2

0

ありがとう、私はこれを解決しました。提案されているように、ログインアクションにリダイレクトを追加する必要がありました。だから私は削除しました

redirect_to favourites_show_path, :action => 'index' and return if current_user

index アクションから、代わりに application_controller.rb に追加されました

def after_sign_in_path_for(resource)
favourites_show_path
end
于 2013-02-21T01:40:38.587 に答える
0

条件から移動し@guidelines...て、検索結果のシンボルの名前を変更するだけです。

def index
  @guidelines = Guideline.order(:title).all
  if params[:search].present?
    @search = Sunspot.search(Guideline) do  
      fulltext params[:search]
    end
    @results = @search.results
  else
    redirect_to favourites_show_path, :action => 'index' and return if current_user
  end
end
于 2013-02-21T01:15:33.457 に答える