Rails. Rewrite clearance controllers -
i try add js in clearance controllers. users-controllers rewrite ok, sessions , passwords controllers not work.
user_controller (work):
class userscontroller < applicationcontroller def new end def create @user = user.new(user_params) if @user.save sign_in @user redirect_to root_path else respond_to :js end end private def user_params params.require(:user).permit( :email, :password, ) end end
sessions_controller (not work):
class sessionscontroller < applicationcontroller def new respond_to :js end def create respond_to :js @user = authenticate(params) sign_in(@user) |status| if status.success? #redirect_back_or url_after_create else respond_to :js end end end end
sessions/new.html.slim :
= form_for :session, html: {id: 'new_session', class: 'new_session'}, url: session_path, remote: true |form| = form.label :email = form.text_field :email = form.label :password = form.password_field :password = form.submit "log in"
sessions/create.js.erb
$(".stuff").prepend("<div>it worked!</div>")
my routes:
sign_in /sign_in(.:format) clearance/sessions#new session /session(.:format) clearance/sessions#new sign_out delete /sign_out(.:format) clearance/sessions#destroy sign_up /sign_up(.:format) clearance/users#new passwords post /passwords(.:format) clearance/passwords#create new_password /passwords/new(.:format) clearance/passwords#new session_index post /session(.:format) clearance/sessions#create user_password_index post /users/:user_id/password(.:format) clearance/passwords#create edit_user_password /users/:user_id/password/:id/edit(.:format) clearance/passwords#edit user_password patch /users/:user_id/password/:id(.:format) clearance/passwords#update put /users/:user_id/password/:id(.:format) clearance/passwords#update users post /users(.:format) users#create
how fix it?
Comments
Post a Comment