Search code examples
ruby-on-railssorcery

Sorcery - signed_in_user


I can get

<% if current_user %>

to work. However I would like to be able to use statments like

<% if current_user=(user) %>

or something like that. How can I do this with Sorcery?


Solution

  • You're trying to use an assignment operator where you need a comparison operator. It should probably be like this:

    <%= if @user == current_user %>
      <!-- Do stuff -->
    <% end %>
    

    Remember you need to get access to the @user instance variable by assigning it in your controller action:

    class UsersController < ApplicationController
      def show
        @user = User.find(params[:id])
      end
    end