Direct button depending on whether the user is logged in or not

0

I have a button that takes to another screen, but if the user is not logged in the system it should redirect to the login screen and not to the one that is already going. Can you do it right on link_to?

li= link_to 'Anuncie', new_subscription_path, class: "button"
    
asked by anonymous 09.05.2018 / 21:47

1 answer

0

I did as follows and it worked

li= link_to_if(@current_user.nil?, "Anuncie seu imóvel", new_user_session_path, class: "button") do
      = link_to  'Anuncie seu imóvel' ,new_subscription_path, class: "button"
      end

I wanted to know if a conditional would work using the button_to instead of link_to

    
10.05.2018 / 20:16