Rails Ajax 500 Internal Server Error
Contents |
here for a quick overview of the site Help Center Detailed answers completed 500 internal server error rails to any questions you might have Meta Discuss the workings
Ruby Completed 500 Internal Server Error
and policies of this site About Us Learn more about Stack Overflow the company Business rails post 500 internal server error Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack
Rails Internal Server Error
Overflow Community Stack Overflow is a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up Why does my rails AJAX request throw internal server error? up vote 0 down vote favorite I have a table , where each line has 500 internal server error ruby on rails a link <%= link_to 'Delete', [lesson.group, lesson], remote: true,method: :delete%> I want the link to destroy the corresponding db entry and remove the corresponding line from the table without reloading the page. The action is def destroy @lesson = @group.lessons.find(params[:id]) @lesson.destroy respond_to do |format| if @lesson format.html { redirect_to edit_group_path(@group), notice:'Succesfully deleted lesson' } format.js {} else format.html { redirect_to edit_group_path(@group), notice:'Error!' } end end end The entries get removed, but I can only see the change when I reload the page, and the console throws DELETE http://localhost:3000/groups/1/lessons/14 500 (Internal Server Error) Extract from the log: Started DELETE "/groups/1/lessons/18" for 127.0.0.1 at 2013-10-24 18:39:22 +0400 Processing by LessonsController#destroy as JS Parameters: {"group_id"=>"1", "id"=>"18"} [1m[36mGroup Load (1.0ms)[0m [1mSELECT "groups".* FROM "groups" WHERE "groups"."id" = ? LIMIT 1[0m [["id", "1"]] [1m[35mLesson Load (1.0ms)[0m SELECT "lessons".* FROM "lessons" WHERE "lessons"."group_id" = 1 AND "lessons"."id" = ? LIMIT 1 [["id", "18"]] [1m[36m (0.0m
here for a quick overview of the site Help Center Detailed answers to any questions
Rails Ajax Form
you might have Meta Discuss the workings and policies of
500 Internal Server Error Ajax Post
this site About Us Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is http://stackoverflow.com/questions/19568667/why-does-my-rails-ajax-request-throw-internal-server-error a community of 6.2 million programmers, just like you, helping each other. Join them; it only takes a minute: Sign up ajax call causes internal server error 500 rails controller up vote 1 down vote favorite I use ruby on rails mvc and I'm trying to use an ajax call to send some http://stackoverflow.com/questions/18305514/ajax-call-causes-internal-server-error-500-rails-controller data back to the server side. I'm confused about how ajax requests are issued and processed in the mvc. ---------------- in my javascript file------------------ $.ajax({ type: 'POST', url: 'http://localhost:3000/locations', data: { lat: position.coords.latitude, lng: position.coords.longitude }, contentType: 'application/json', dataType: 'json' }); I'm using a respond_to block to catch this request in my controller: ---------------- in my home controller ------------------ respond_to do |format| format.js { render 'users/locations' } format.html {} end ---------------- route.rb ------------------------ post 'users/locations' get 'users/locations' match "/locations", to: "users#locations" I tried to extract the data this way: ---------------- in my locations action------------------ dasdasdd // used as a breakpoint to test whether this part was executed. it wasn't. current_user.update_attribute :Latitude, params[:lat] current_user.update_attribute :Longitude, params[:lng] With the debugging firefox console, I see a internal servers error 500. This might explain why the locations action was never executed. But why is there an error 500? Can anybody shine some light into how I might be wrong? ruby-on-rail
Sign in Pricing Blog Support Search GitHub This repository Watch 451 Star 7,884 Fork https://github.com/spree/spree/issues/2517 3,669 spree/spree Code Issues 137 Pull requests 77 Projects 0 Wiki Pulse Graphs New issue POST /orders/populate 500 Internal Server Error on ajax cart update #2517 Closed sibsfinx opened this Issue Feb 2, 2013 · 8 comments Labels None yet Milestone No milestone Assignees No one assigned internal server 3 participants sibsfinx commented Feb 2, 2013 Hello, I'm adding a product to cart with = form_for :order, :url => populate_orders_path, :remote => true, ... and handling events with .on('ajax:success') .on('ajax:error') and so on. I've added in orders_controller respond_to :html, :js and (in def populate) respond with(@order) do |format| format.html internal server error { redirect_to cart_path } format.js end but I'm getting the following error: (javascript console) POST http://localhost/orders/populate 500 (Internal Server Error) (server log) ActionView::MissingTemplate - Missing template spree/orders/populate, spree/store/populate, spree/base/populate, application/populate with {:locale=>[:ru], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :haml, :rabl], :versions=>[:v1]}. Spree Commerce member radar commented Feb 3, 2013 Please show us your Gemfile. … On 03/02/2013, at 4:39, Alexander Mescheryakov ***@***.***> wrote: Hello, I'm adding a product to cart with = form_for :order, :url => populate_orders_path, :remote => true, ... and handling events with .on('ajax:success') .on('ajax:error') and so on. I've added in orders_controller respond_to :html, :js and (in def populate) respond ***@***.***) do |format| format.html { redirect_to cart_path } format.js end but I'm getting the following error: (javascript console) POST http://localhost/orders/populate 500 (Internal Server Error) (server log) ActionView::MissingTemplate - Missing template spree/orders/populate, spree/store/populate, spree/base/populate, application/populate with {:locale=>[:ru], :formats=>[:js, :html], :handlers=>[:erb, :builder, :coffee, :haml, :rabl], :versions=>[:v1]}. — Reply t