Ruby on Rails - £ Sign Troubles

Ruby on Rails - £ sign troubles

Suggestion from my experience) :

  1. verify that your file erb is saved in utf-8
  2. I recomend you to use number_to_currency method

Login/Logout Trouble

I would suggest to use Devise gem, but if you wish to create your own authentication logic try following code:

in your application_controller.rb add this:

before_filter :login_required!

def login_required!
unless logged_in?
redirect_to '/login'
end
end

def logged_in?
current_user
end

def current_user
@current_user ||= User.find(session[:user_id])
end

in view add this:

<% if @current_user %>
<%= link_to("Logout", destroy_user_session_path, :method => :delete) %>
<% else %>
<%= link_to 'Login', new_user_session_path %>
<% end %>

with Devise you do like this:

  <% if user_signed_in? %>
<%= link_to("Logout", destroy_user_session_path, :method => :delete) %>
<% else %>
<%= link_to 'Login', new_user_session_path %>
<% end %>

check out the Devise documentation here

problem with login page ruby on rails

I think you want render :action => 'private' instead of a redirect.

trouble logging in to rails app after logout

Ok. The issue was here... The answer I received was a bit of a workaround which is not at all what I need when I'm learning. So in my sessions_controller, I was defining a user by the params specified for the user in the users_controller. What I needed to do was define say login_params within the sessions_controller.. either that or in the create method .find_by_email(params[user.email]). I chose to create this private method at the bottom and changed the
.find_by_email(params[:email]) and the authenticate(params[:password])
to
.find_by_email(login_params[:email]) and the authenticate(login_params[:password])

 private

def login_params
params.require(:user).permit(:email, :password)
end

Ruby on Rails: Unable to sign out of application in production

It might be related to jQuery.

Be sure to have the following lines in your application.js file (app/assets/javascripts/application.js), before any other entry:

//= require jquery 
//= require jquery_ujs

A quick fix would be to change the signout method on devise.rb initializer (config/initializers/devise.rb):

config.sign_out_via = :get

having problems with the login link using Spree

Your override file at app/overrides/auth_login_bar.rb is telling Spree to insert a partial view called spree/shared/login_bar into the nav bar. Did you create this partial in your views?

Here's my partial view (written in HAML), located at spree/shared/_login_bar.html.haml

- if spree_current_user
%li= link_to(Spree.t(:logout), destroy_spree_user_session_path, method: :delete)
- else
%li= link_to(Spree.t(:login), login_path)
%li= link_to(Spree.t(:signup), signup_path)

You could also remove the method: :delete from the second line to make it a get request, which I think is how Spree is set up now.

Problems with sign up, rails

I think you are creating the session before saving the user, it doesn't have and id yet (its created on save). I think you should try something like:
....

if @user.save
..do your thing..
sign_up @user
else
.. another thing..
end

...



Related Topics



Leave a reply



Submit