1

This is my first question on StackOverflow. I am new to Rails and am making a simple Rails app in which I am doing a modal popup for user login in. My code is below.

App/Controller/Sessions:

class Users::SessionsController < Devise::SessionsController
 # respond_to :html, :json
 # before_action :check_user_session, only: [:new]
 # GET /resource/sign_in
 def new
 self.resource = resource_class.new(sign_in_params)
 clean_up_passwords(resource)
 yield resource if block_given?
 respond_to do |format|
 format.js
 format.html
 end
 end
 # POST /resource/sign_in
 def create
 self.resource = warden.authenticate(auth_options)
 if self.resource.present?
 set_flash_message(:notice, :signed_in)
 sign_in(resource_name, resource)
 yield resource if block_given?
 respond_with resource, location: after_sign_in_path_for(resource)
 else
 respond_to do |format|
 format.js
 end
 end
 end

My new.js.haml file:

$("#login-modal").html("#{escape_javascript(render 'new')}");
$("#exampleModal").modal();

I am getting this error when I click the sign in button.

Leopold Joy
4,6704 gold badges30 silver badges38 bronze badges
asked Nov 30, 2017 at 7:41
5
  • Might have something to do with class Users::SessionsController < Devise::SessionsController (your first line). I don't know much about ruby, but seems like < is unexpected there Commented Nov 30, 2017 at 7:44
  • no that is not the issue with class Users::SessionsController < Devise::SessionsController because this is my controller and it is inherrited by devise Commented Nov 30, 2017 at 8:11
  • Well then, don't you miss an end at the end ? Commented Nov 30, 2017 at 8:17
  • can you share you new.html.erb or the sign_in form? Commented Nov 30, 2017 at 8:27
  • Can you post the full error trace ? Commented Dec 1, 2017 at 21:55

1 Answer 1

1

change file new.js.haml to new.js.erb with following code:

$("#login-modal").html("<%= escape_javascript(render 'new') %>");
$("#exampleModal").modal();
answered Nov 30, 2017 at 10:15
Sign up to request clarification or add additional context in comments.

1 Comment

have you changed file extension to js.erb?

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.