Ruby on Rails ajax 500 syntax error -



Ruby on Rails ajax 500 syntax error -

i have static controller , users controller.

i have users profile page , want utilize ajax replace existing code form partial. on page, have edit button routes edit action in users controller , goes edit.js.erb view. in view have next code:

$("<%= escape_javascript(render 'static/profile_form'%>").appendto("#ajax-profile");

everytime seek , create work, error this:

started "/users/edit" 127.0.0.1 @ 2014-10-05 17:42:19 -0400 started "/users/edit" 127.0.0.1 @ 2014-10-05 17:42:19 -0400 processing userscontroller#edit js processing userscontroller#edit js user load (0.1ms) select "users".* "users" "users"."id" = ? limit 1 [["id", 2]] user load (0.1ms) select "users".* "users" "users"."id" = ? limit 1 [["id", 2]] rendered users/edit.js.erb (1.0ms) rendered users/edit.js.erb (1.0ms) completed 500 internal server error in 61ms completed 500 internal server error in 61ms syntaxerror (/users/usernameredacted/desktop/magazine_alive/yourcoolapp/app/views/users/edit.js.erb:1: syntax error, unexpected tlabel, expecting ')' ...tput_buffer.append=( j (render: 'static/profile_form' );@out... ... ^): app/views/users/edit.js.erb:1: syntax error, unexpected tlabel, expecting ')' syntaxerror (/users/usernameredacted/desktop/magazine_alive/yourcoolapp/app/views/users/edit.js.erb:1: syntax error, unexpected tlabel, expecting ')' ...tput_buffer.append=( j (render: 'static/profile_form' );@out... ... ^): app/views/users/edit.js.erb:1: syntax error, unexpected tlabel, expecting ')'

i have been creating users through console, have yet fill out form user. problem? there no info edit? don't want new/create view because have login page users.

in users controller have:

class userscontroller < applicationcontroller def create @user= user.find_by(session[:user_id]) @user.create(user_params) end def edit @user= current_user end def update @user=current_user @user.update(user_params) end private def user_params params.require(:user).permit(:first_name,:last_name,:email,:bio,:avatar) end end

static controller

def profile @my_articles = article.all.order('created_at desc').where(:user_id => current_user).limit(5); @user= current_user end

so error says:

app/views/users/edit.js.erb:1: syntax error, unexpected tlabel, expecting ')'

its expecting closing parentheses. if @ code:

$('#ajax-profile').prepend(" <%= j (render: 'static/profile_form' %> ");

you notice have mismatched parenthesis.

i suspect need alter code this

$('#ajax-profile').prepend(" <%= j (render: 'static/profile_form' )%> ");

ruby-on-rails ajax internal-server-error

Comments

Popular posts from this blog

Delphi change the assembly code of a running process -

json - Hibernate and Jackson (java.lang.IllegalStateException: Cannot call sendError() after the response has been committed) -

C++ 11 "class" keyword -