I'm using devise on my project, i want to update others profile from my admin panel, so only users with admin role can access it, since this behavior is very different to the default devise, i decided to create a separated controller, so i can manipulate users as normal records, but for some reason when i update users, the records are not updated into the database.
THESE ARE MY ROUTES
devise_for :users, controllers: { registrations: 'users/registrations' }
root "users#index"
post "users/:id" => "users#show"
get "users/:id" => "users#show", as: :user
patch "users/:id" => "users#show"
resources :receipts
resources :notes
get "users/edit/:id" => "users#edit", as: :edit_user
THIS IS MY CONTROLLER
def edit
#user = User.find(params[:id])
end
def update
user = User.find(params[:id])
user.update(user_update_params)
redirect_to user
end
private
def user_update_params
params.require(:user).permit(:username, :names, :last_names, :guardian, :phone, :identification, :role)
end
def user_params
if #user.debts.nil?
params.require(:user).permit(:debts)
else
params.require(:user).permit(:add_debt)
end
end
THESE IS MY VIEW
<% if current_user && current_user.has_role?(:admin) %>
<div class="container form-bg">
<div class="row main">
<div class="panel-heading">
<div class="panel-title text-center">
<h1 class="title">Editar usuario</h1>
<hr />
</div>
</div>
<div class="main-login main-center">
<%= form_for #user do |f| %>
<div class="form-group">
<%= f.label :username, "Usuario" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<%= f.text_field :username, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :names, "Nombres" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<%= f.text_field :names, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :last_names, "Apellidos" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<%= f.text_field :last_names, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :phone, "Teléfono" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-phone fa" aria-hidden="true"></i></span>
<%= f.text_field :phone, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :identification, "Número de identification" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-envelope fa" aria-hidden="true"></i></span>
<%= f.text_field :identification, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :guardian, "Guardian legal" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-user fa" aria-hidden="true"></i></span>
<%= f.text_field :guardian, autofocus: true, class: "form-control" %>
</div>
</div>
</div>
<div class="form-group ">
<label>
<%= f.radio_button :role, "student" , :checked => true %>
Estudiante
</label>
<label>
<%= f.radio_button :role, "teacher" %>
Profesor
</label>
</div>
<div class="form-group">
<%= f.label :password, "Contraseña" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa" aria-hidden="true"></i></span>
<% if #minimum_password_length %>
<em>(<%= #minimum_password_length %> characters minimum)</em>
<% end %>
<%= f.password_field :password, autofocus: true, class: "form-control", autocomplete: "off" %>
</div>
</div>
</div>
<div class="form-group">
<%= f.label :password_confirmation, "Confirmar contraseña" ,class: "cols-sm-2 control-label" %><br />
<div class="cols-sm-10">
<div class="input-group">
<span class="input-group-addon"><i class="fa fa-lock fa" aria-hidden="true"></i></span>
<%= f.password_field :password_confirmation, autofocus: true, class: "form-control", autocomplete: "off" %>
</div>
</div>
</div>
<div class="form-group ">
<%= f.submit "Editar", class: "btn btn-primary btn-lg btn-block login-button" %>
</div>
<% end %>
</div>
</div>
<p class="invisible">asdsadsadsdsadsad</p>
</div>
<% else %>
<h1>Acceso exclusivo para administradores</h1>
<% end %>
So after reading my stack trace, it indeed tries to make the patch, but then it says that the params are not permitted, which is very weird since i already did permit them on my user_update_params method.
this what appears on my trace
Started PATCH "/users/12" for ::1 at 2017-01-28 13:20:53 -0500
Processing by UsersController#show as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"IdJKYYFVh8ZJJm/RPRJd7blfQw84Ct38KjE5tZ6fTuHFK8TG04MxUu2OtQv6wfLvFJll0EYYZa+ooxP19RqOAQ==", "user"=>{"username"=>"jimena", "names"=>"Jimena44", "last_names"=>"Delgado Díaz44", "phone"=>"214123244", "identification"=>"32312", "guardian"=>"3213123", "role"=>"student", "password"=>"[FILTERED]", "password_confirmation"=>"[FILTERED]"}, "commit"=>"Editar", "id"=>"12"}
User Load (0.5ms) SELECT "users".* FROM "users" WHERE "users"."id" = ? LIMIT 1 [["id", 12]]
Unpermitted parameters: username, names, last_names, phone, identification, guardian, role, password, password_confirmation
So why are my files not being updated if it even redirects as it is intended on the controller?
Thanks for reading.
Since you are using devise I think you need to set it up like this:
before_action :configure_permitted_parameters
protected
def configure_permitted_parameters
devise_parameter_sanitizer.for(:account_update) << [:username, :names]
end
Make sure the controller is inheriting from devise:
class UsersController < Devise::RegistrationsController
You can read more about it here and here, in the parts about strong parameters.
Related
Hopefully someone can help me out with this! I am trying to implement stripe elements in rails and basically what I have is an Orders class, but the person checking out has the option to choose between two forms... the first form has two additional field options for them to fill out if the click this option. The second option has two less fields to fill out in the order form. Right now I am rendering this form as a partial and I am restricting whether or not the two conditional fields are shown by passing a local to the form partial. This is all working great. What is NOT working, is that my Stripe elements tag is rendering fine on the first form render, but it never renders in a functional state or with any css styles on the second form. The stripe_elements_tag in the second rendered version of the tag is totally useless. Can anyone think of a better way to do this or a fix that might work? I tried hiding the content in the divs and displaying it with an on click, show the form, but this also did not work. The second form would never be shown ( i noticed this option also made the form animations slower :( .
At this point I am considering actually just writing two separate forms even though thats not very DRY just to see if it will work that way.
Any ideas or thoughts are very much welcomed!
Have a great day everyone!
here is my new.html.erb code
<%= stripe_javascript_tag %>
<div class="container">
<div class="mx-auto" width="400px">
<div class="accordion" id="accordionExample">
<div class="card">
<div class="card-header" id="headingOne">
<h5 class="mb-0">
<button class="btn btn-link" type="button" data-toggle="collapse" data-target="#collapseOne" aria-expanded="true" aria-controls="collapseOne">
Referred By Group
</button>
</h5>
</div>
<div id="collapseOne" class="collapse" aria-labelledby="headingOne" data-parent="#accordionExample">
<div class="card-body">
<%= render "order_form", locals: { buy_method: "group" } %>
</div>
</div>
</div>
<div class="card">
<div class="card-header" id="headingTwo">
<h5 class="mb-0">
<button class="btn btn-link collapsed" type="button" data-toggle="collapse" data-target="#collapseTwo" aria-expanded="false" aria-controls="collapseTwo">
Purchasing Independently
</button>
</h5>
</div>
<div id="collapseTwo" class="collapse" aria-labelledby="headingTwo" data-parent="#accordionExample">
<div class="card-body">
<%= render "order_form", locals: { buy_method: "individual" } %>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="col-md-6" id="flash-message">
<%= render partial: 'flash' %>
<% #order.errors.full_messages.each do |msg| %>
<li> * <%= msg %> </li>
<% puts msg %>
<% end %>
</div>
<div class="row">
<div class="col-md-9 mb-md-0 mb-5">
<%= form_for #order do |f| %>
<div class="row">
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :customer_name, "Your Name *" %><br />
<%= f.text_field :customer_name, class: "form-control" %>
</div>
</div>
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :email, "Email *" %><br />
<%= f.text_field :email, class: "form-control" %>
</div>
</div>
</div>
<% if locals[:buy_method] == "group"%>
<div class="row">
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :student_name, "Student Name *" %><br />
<%= f.text_field :student_name, class: "form-control" %>
</div>
</div>
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :school_name, "School or Group Name *" %><br />
<%= f.text_field :school_name, class: "form-control"%>
</div>
</div>
</div>
<% end %>
<div class="row">
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :street_address, "Street Address *" %><br />
<%= f.text_field :street_address, class: "form-control" %>
</div>
</div>
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :number_books, "Number of books to purchase *" %><br />
<%= f.select :number_books, (0..99), class: "form-control", selected: 0%>
</div>
</div>
</div>
<div class="row">
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :city, "City *" %><br />
<%= f.text_field :city, class: "form-control" %>
</div>
</div>
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :state, "State *" %><br />
<%= f.select :state, [ "--",'AL', 'AK', 'AS', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FM', 'FL', 'GA', 'GU', 'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MH', 'MD', 'MA', 'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY', 'NC', 'ND', 'MP', 'OH', 'OK', 'OR', 'PW', 'PA', 'PR', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VT', 'VI', 'VA', 'WA', 'WV', 'WI', 'WY' ], class: "form-control"%>
</div>
</div>
<div class="col-md-6">
<div class="md-form mb-0">
<%= f.label :zip_code, "Zip code *" %><br />
<%= f.text_field :zip_code, class: "form-control" %>
</div>
</div>
</div>
<br>
<div class="row">
<div class="col-md-6">
<div class="checkbox">
<%= f.check_box :email_permission, checked: "checked", checked_value: true, unchecked_value: false %>
<%= f.label :email_permission, class: "checkbox-inline" %>
</div>
</div>
</div>
<div class="form-group">
<label for="card-element">Credit or debit card *</label>
<div id="card-element" class="form-control" >
<%= stripe_elements_tag submit_path: contact_index_path %>
</div>
</div>
<div class="form-group">
<%= f.label :total %>
<%= f.label :total, id: "total", value: "$#{ #order.total }" %>
</div>
<%= f.submit "Submit", class: "btn btn-default btn-primary" %>
</div>
<% end %>
</div>
</div>
You need to create two separate Instances of the card referencing your stripe api_key two separate times. You cannot create two elements using the same instantiation of your stripe api key.
As i been work for this project for while, as this one was not on the scopes, until yesterday, as the clients and project manager change mind as they want two different signup as it was one single sign up before but now want change two, but i was thinking it possible use same one user, but different path
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h2 class="text-center">Sign up</h2>
</div>
<div class="col-sm-offset-4 col-sm-4 margin-button-bottom">
<div class="col-sm-12 text center">
<div class="inner-addon right-addon">
<i class="custom custom-icon-arrow-right"></i>
<%= link_to "I want hire Equipment", new_user_registration_path, class: "btn btn-black-free-account btn-lg btn-block", role:"button" %>
</div>
</div>
</div>
<div class="col-sm-offset-4 col-sm-4 margin-button-bottom">
<div class="col-sm-12 text center">
<div class="inner-addon right-addon">
<i class="custom custom-icon-arrow-right"></i>
<p><%= link_to "I represent a business with equipment available for hire", new_user_registration_path, class: "btn btn-black-free-account btn-lg btn-block", role:"button" %></p>
</div>
</div>
</div>
<br/>
so if this button "I represent a business with equipment available for hire" show form same as user but add field is Company
Here is two different
devise register new.html.erb
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h2 class="text-center">Sign up</h2>
<br />
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render 'shared/regmessage' %>
<div class="form-group">
<%= f.text_field :fullname, autofocus: true, placeholder: "Full name", class: "form-control", autocomplete: "fullname" %>
</div>
<div class="form-group">
<%= f.email_field :email, autofocus: true, placeholder: "Email", class: "form-control", autocomplete: "email" %>
</div>
<div class="form-group">
<% if #minimum_password_length %>
<em>(
<%= #minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, placeholder: "Password", class: "form-control", autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Sign up", class: "btn btn-black-free-account btn-block" %>
</div>
<% end %>
<hr />
<%= link_to user_facebook_omniauth_authorize_path, class: "btn btn-block btn-social btn-facebook" do %>
<span class="fa fa-facebook"></span> Sign in with Facebook
<% end %>
<hr />
<%= link_to user_google_oauth2_omniauth_authorize_path, class: "btn btn-block btn-social btn-google" do %>
<span class="fa fa-google"></span> Sign in with Google
<% end %>
<br/>
</div>
</div>
same as above but add is company field in the new_company.html.erb
<div class="row">
<div class="col-md-4 col-md-offset-4">
<h2 class="text-center">Sign up</h2>
<br />
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= render 'shared/regmessage' %>
<div class="form-group">
<%= f.text_field :company, autofocus: true, placeholder: "Company Name", class: "form-control", autocomplete: "Company-name" %>
</div>
<div class="form-group">
<%= f.text_field :fullname, autofocus: true, placeholder: "Full name", class: "form-control", autocomplete: "fullname" %>
</div>
<div class="form-group">
<%= f.email_field :email, autofocus: true, placeholder: "Email", class: "form-control", autocomplete: "email" %>
</div>
<div class="form-group">
<% if #minimum_password_length %>
<em>(
<%= #minimum_password_length %> characters minimum)</em>
<% end %><br />
<%= f.password_field :password, placeholder: "Password", class: "form-control", autocomplete: "new-password" %>
</div>
<div class="actions">
<%= f.submit "Sign up", class: "btn btn-black-free-account btn-block" %>
</div>
<% end %>
<br/>
<%= link_to user_facebook_omniauth_authorize_path, class: "btn btn-block btn-social btn-facebook" do %>
<span class="fa fa-facebook"></span> Sign in with Facebook
<% end %>
<br/>
<%= link_to user_google_oauth2_omniauth_authorize_path, class: "btn btn-block btn-social btn-google" do %>
<span class="fa fa-google"></span> Sign in with Google
<% end %>
<br/>
</div>
</div>
Route.rb
devise_for :users,
path: '',
path_names: {sign_in: 'login', sign_out: 'logout', edit: 'profile', sign_up: 'registration'},
:controllers => {omniauth_callbacks: 'omniauth_callbacks', registrations: 'registrations', }
register controller.rb
class RegistrationsController < Devise::RegistrationsController
protected
def update_resource(resource, params)
resource.update_without_password(params)
end
end
I was thinking something like java-script or controller if i click business button then the route will know and add company field into new.html.erb rather decided to go which one of two new and new company.html.erb
maybe new ID in the new.html.erb or need configure at route or controller?
In your registrations controller set a flag variable #for_company for example based on the params[:for_company] presence:
class RegistrationsController < Devise::RegistrationsController
def new
#for_company = params[:for_company].present?
super
end
end
And in your Sign Up page simply add for_company: true param to a link to a company sign up:
<%= link_to "I represent a business with equipment available for hire", new_user_registration_path(for_company: true), class: "..." %>
Then just show :company field in case if #for_company is true.
I have created a HTML form which works fine on my development and staging servers, however it is not working on the production environment.
Staging and production server URLs can be reached below:
Staging
Production
I am quite new to Rails and I will appreciate any kind of support. Below you can find the form code in the view template:
<%= form_for(#referral_form, url: submit_referral_form_url, method: :post, :remote => true ) do |f| %>
<div class="contact-us-error"><ul></ul></div>
<div class="form-group has-success has-feedback">
<%= f.text_field :name, :class=>"form-control", :placeholder => "Adınız & Soyadınız", required: true %>
<span class="glyphicon glyphicon-user form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-success has-feedback">
<%= f.text_field :phone, :class=>"form-control", :placeholder => "Telefon Numaranız", required: true %>
<span class="glyphicon glyphicon-phone form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-success has-feedback">
<%= f.text_field :friend_name, :class=>"form-control", :placeholder => "Arkadaşınızın Adı & Soyadı", required: true %>
<span class="glyphicon glyphicon-user form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-success has-feedback">
<%= f.text_field :friend_phone, :class=>"form-control", :placeholder => "Arkadaşınızın Telefon Numarası", required: true %>
<span class="glyphicon glyphicon-phone form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-success has-feedback">
<%= f.email_field :email, :class=>"form-control" , type:'email', required: true, placeholder: "Email Adresiniz" %>
<span class="glyphicon glyphicon-envelope form-control-feedback" aria-hidden="true"></span>
</div>
<div class="form-group has-success has-feedback">
<%= f.text_area :message, :class=>"form-control", :placeholder=>"Arkadaşınızın Arabasının Özelliği (Yıl, Marka, Model vb)", required: true %>
</div>
<div class="form-group has-success has-feedback">
<%= f.hidden_field :campaign_name, :value => "Nusret-2017"%>
</div>
<div class="form-group has-success has-feedback">
<%= f.submit "Gönder", class: "btn createaccbtn" %>
</div>
<% end %>
If you can use a relative path then just change submit_referral_form_url to submit_referral_form_path
In my edit view, I want to apply bootstrap. However, when replacing...
<%= form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
<%= devise_error_messages! %>
<div class="row">
<div class="col-md-6">
<div class="row form-group">
<div class="col-md-4"><%= f.label :username %></div>
<div class="col-md-8"><%= f.text_field :username %></div>
</div>
with this...
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class="sr-only" for="username">Username</label>
<input type="text" class="form-control" name="username" placeholder="Username" value="<%= f.text_field :username %>">
</div>
</div>
</div>
I get this as output
I have tried many alternatives to include erb but don't understand the issue. How should I include the field in my edit forms?
you can do all the things with rails.
<div class="row">
<div class="col-md-4">
<div class="form-group">
<%= f.label :username %>
<%= f.text_field :username, class: "form-control", placeholder: "Username" %>
</div>
</div>
</div>
For more detail Please visit this link
http://apidock.com/rails/ActionView/Helpers/FormHelper/text_field
If you want to use add-on you can as below
<div class='input-group' >
<%= f.text_field :username, class: "form-control", placeholder: "Username" %>
<span class="input-group-addon" id="basic-addon2">#example.com</span>
</div>
Try this instead
<div class="row">
<div class="col-md-4">
<div class="form-group">
<label class="sr-only" for="username">Username</label>
<%= f.text_field :username, class: "form-control", placeholder: "Username" %>
</div>
</div>
</div>
I would suggest using a gem called simple_form, it's made by the creators of Devise and works nicely with Bootstrap. It also has nice validation errors.
https://github.com/plataformatec/simple_form
Here's an example:
= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f|
.form-inputs
= f.input :email, required: false, autofocus: true, placeholder: 'Email'
= f.input :password, required: false, placeholder: 'Password'
= f.input :remember_me, as: :boolean, label: 'Remember Me' if devise_mapping.rememberable?
.form-actions
= f.button :submit, 'Sign in', class: 'btn-block btn-success'
%br
= link_to 'Forgot your password?', new_user_password_path
The code above will automatically add any bootstrap classes and labels...etc
I am using a Wrapbootstrap downloaded template, with devise for user registration and log in but am not getting any errors to pop up.
In all my views for devise I am calling <%= devise_error_messages! %>
In my model the following validations:
validates :first_name, presence: true
validates :last_name, presence: true
validates :phone_number, presence: true
Here is my Devise_helper.rb
module DeviseHelper
def devise_error_messages!
return '' if resource.errors.empty?
messages = resource.errors.full_messages.map { |msg| content_tag(:li, msg) }.join
html = <<-HTML
<div class="alert alert-error alert-block"> <button type="button"
class="close" data-dismiss="alert">x</button>
#{messages}
</div>
HTML
html.html_safe
end
end
Here is my Registration New view page:
<!--=== Content Part ===-->
<div class="container content">
<div class="row">
<div class="col-md-6 col-md-offset-3 col-sm-8 col-sm-offset-2">
<form class="reg-page">
<div class="reg-header">
<h2>Register a new account</h2>
<p>Already Signed Up? Click <%= link_to "Sign In", login_url %> to login your account.</p>
</div>
<%= form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
<%= devise_error_messages! %>
<label>First Name<span class="color-red">*</span></label>
<%= f.text_field :first_name, autofocus: true, :class=> "form-control margin-bottom-20" %>
<label>Last Name<span class="color-red">*</span></label>
<%= f.text_field :last_name, autofocus: true, :class=> "form-control margin-bottom-20" %>
<label>Phone Number<span class="color-red">*</span></label>
<%= f.text_field :phone_number, autofocus: true, :class=> "form-control margin-bottom-20" %>
<label>Email Address <span class="color-red">*</span></label>
<%= f.email_field :email, autofocus: true, :class=> "form-control margin-bottom-20" %>
<div class="row">
<div class="col-sm-6">
<label>Password <span class="color-red">*</span></label>
<% if #validatable %>
<em>(<%= #minimum_password_length %> characters minimum)</em>
<% end %>
<%= f.password_field :password, autocomplete: "off", :class=> "form-control margin-bottom-20" %>
</div>
<div class="col-sm-6">
<label>Confirm Password <span class="color-red">*</span></label>
<%= f.password_field :password_confirmation, autocomplete: "off",:class=> "form-control margin-bottom-20" %>
</div>
</div>
<hr>
<div class="row">
<div class="col-lg-6 text-right">
<%= f.submit "Sign up", :class=> "btn-u" %>
</div>
</div>
</form>
</div>
</div>
<% end %>
</div><!--/container-->
<!--=== End Content Part ===-->
And when I submit an uncomplete form a query string like this is generated: http://localhost:3000/login?utf8=%E2%9C%93&authenticity_token=v%2BKndd3om3fBChpsZ6riw%2FVBiVM1ehVbKgBF9tIlg6PB6p30oei7OU3toqthjU1TY67yI3gmzjigxGe5DWfX7w%3D%3D&user%5Bemail%5D=&user%5Bpassword%5D=fwf&user%5Bremember_me%5D=0&commit=Log+in
Try with this in your helper file:
message_html << "<div class="alert alert-error alert-block"> <button type="button" class="close" data-dismiss="alert">x</button>"
message_html.html_safe
Also, check for flash message in your layout page or corresponding login page as:
<% if flash[:alert] %>
<span class='flash_error'> <%= flash[:alert] %></span>
<% end %>
There reason for this was because the template I was using had its own Javascript for error messages that was overriding the error messages of devise. Both error messages were not showing up until I removed the JS included in the Wrapbootstrap template and it works now