Ruby on Rails - £ sign troubles
Suggestion from my experience) :
- verify that your file erb is saved in utf-8
- 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
How to Update a Model's Attribute with a Virtual Attribute
Ruby Gem Cucumber Ssl Error and Gem Sources
Uploading a File to a S3 Presigned Url
How to Get the File Creation Time in Ruby on Windows
Permanently Switching User in Capistrano 3 (Separate Authorization & Deploy)
How to Http Post Stream Data from Memory in Ruby
How to Set the Mechanize Page Encoding
Rails Not Working for New Project. Showingerror " Superclass Mismatch for Class Cipher (Typeerror)"
Calling a Method of a Ruby Singleton Without the Reference of 'Instance'
Exclude Some Ids from Result in Rails Activerecord
Ruby Gsub Problem When Using Backreference and Hashes
Flatten a Ruby Array Without Using Built-In 'Flatten' Method
Rails: Merit Gem Badge Not Registering or Displaying
P Method in Ruby Hard to Search For
Gem Install Wrong Number of Arguments (Given 4, Expected 1)
Ruby Syntax Question: Rational(A, B) and Rational.New!(A, B)
Chrome Asks to "Select a Certificate" for Ssl on My Rails App Using Thin