Reputation: 14978
I am unable to display notice
variable in my template. Code is below:
class UserController < ApplicationController
protect_from_forgery
skip_before_filter :require_login, :except=>[:list,:add,:delete,:update]
def add
end
def delete
end
def update
end
def list
end
def login
end
def logout
end
def isloggedin
login = params[:login].to_s
password = params[:password].to_s
logged_in = User.where(:user_name => login,:password => password).limit(1)
if not logged_in.blank?
session[:userinfo] = logged_in
redirect_to '/event/list'
else
flash[:notice] = 'Unable to login'
redirect_to '/user/login'
end
end
end
Template file
<div><%= notice %></div>
Upvotes: 0
Views: 293
Reputation: 14978
It was because I was getting error Can't verify CSRF token authenticity
. I added following input field in form and it started showing message:
<input name="authenticity_token" type="hidden" value="<%= form_authenticity_token %>" />
Upvotes: 0
Reputation: 503
Add this into your template file:
<% flash.each do |key, value| %>
<div class="alert alert-<%= key %>"><%= value %></div>
<% end %>
So when your run your code next time key is replace with "notice" and value with "unable to login"
Hope this help! Thanks
Upvotes: 2