ActionController::UnknownFormat with format.js for ajax implementation (Rail 4) -


I try to use Ajax in my application with the railway. 4. The customer I use to my JS I send it to:

  Answer_ | Format | Format.js end  

But this error generates in my controller "ActionController :: UnknownFormat" Can I help my controller someone please me?

main_controller.rb:

  class oweb :: mancontroller & lt; ApplicationController def index ..... enddef setmagsasstats start @mag = megasin.find (paramus [: id]) if @ megtatmagasin.lib == 'ovate' @ megtatmagcin = atatamagasin. Where (Lib: 'Fermae'). Second first @ mega.totmagasin = Atatamagasin Where (Lib: 'Overt') First end rescue ActiveRecord :: RecordNotFound logger.error (attempt to use "invalid Magasin # {params [: id]}") redirect_to_index ("Invalid Magasin") and @ mag.save @ mags = Magasin.where (user_id: Current_user.id) response_to do | Format | Format.js End of End End  

setmagasinstatus.js.erb:

  p.a. place_html ("bloc_magasin",: partial => "listmagasins " html> html> head meta charset =" utf-8 " 

layout / application.html.slim:

  doctype html html head Meta pigment = "utf-8" meta http-equiv = "x-UA-compatible" content = "IE = edge" meta name = "viewport" content = "width = device-width, initial-scale = 1.0" meta name = "Description" content = "" meta name = "author" content = "" title = yield (title) = stylesheet_link_tag "application" = csrf_mata_ Bag body ......... = yield = javascript_in clude_tag "application" = yield: script  

gemfile:

  source 'https: / /rubygems.org 'Ranks instead of #bundle shore: Rail' rail ', github:' rail / rail 'gem' rail ',' 4.1.1 'group: development gem' mysql2 'end group: production mani' pg 'End gem' sass-rail ',' ~> 4.0.3 'gem' euglaform ',' gt = 1.3.0 'gem' coffee-rail ',' ~ & gt; 4.0.0 'Gem' Thermibrracy ', Platform: Ruby Mani' Jackry-Rail 'Mani' TurboLinks 'Gem' jbuilder ',' ~ & gt; 2.0 'Mani' sdoc ',' ~ & gt; 0.4.0 ', Group :: Doctor Mani' Spring ', Group :: Vikas Mani' Deity ',' ~ & gt; 3.2.4 'Gem' Slim-Rail ',' ~ & gt; 2.1.4 'Gem' bootstrap-saas ',' ~ & gt; 3.1.1.1 'gem' compass-rail, '~ & gt; 1.1.7 'Gem' simple_form ',' ~ & gt; 3.0.2 'Mani Active Action', Gitb: 'Grabble / Active' Admin 'Mani' Polymerus', Gitub: 'activative-hackeri' / polileries' mani 'Rishak', Gitub: 'ActiveCord-Hackeri / Rishak' Mani 'formistic ', Gitub:' Justinfrench / formtastic 'Mani' Debugger ', Group: [: Development, Test :: Production] Mani' GeoCoder 'Mani' gmaps4rails ',' ~ & gt; 2.1.2 ' 

log:

  2014-08- 1 for 19 2.168.56.1 "/ oweb / main / setmagasinstatus? Id = 3 "has been started? 01 06:22:06 OBB :: ManController # 10000 Processing as HTML parameter by Samsung Incentus: {"id" =>, "3"} is not acceptable in full 406 103ms ActionController: UnknownFormat (ActionController :: UnknownFormat) : App / Controller / oweb / main_controller.rb: 24: Rendered in 'Settmagas Instance' / Home / Widget / RVM / Games / Ruby -2.1.1 / Games / ActivitiesPak-4.1.1 / Lib / Activity_Dispatch / Milfware / Templates / Paints / _source.erb (2.1ms) Rated / Home / Widget / RVM / Games / Ruby -2.1.1 / Games / ActivitiesPac-4.1.1 / Lib / Activity_Dispech / Milfle / Templates / Paints /_trace.html.erb (2.2 MMS) Rated / Home / Vigent / RVM / Games / Ruby -2.1.1 / Games / transactionpack-4.1.1 / lib / process_despech / milkfill / templates / paints / _requist_ and_processemate.rbi (1.1 mms) rated / home / violett / .rvm / gemma / ruby ​​- 2.1.1 Gemstone / Action Pack-4.1.1 / Leab / Action_Dispatch / Middleware / Template / Resusues / Diagnostics RB saves / layout (27.1 ms)  

hold:

Your console login says:

OWeb :: ManController # Setgages by Instantus as HTML

In your controller action, you have not supported the don HTML response, that is why you are facing an error of unknown format .

Solution:

Add the format: "js" for example in your AJAX call:

  $ Ajax url: "/ oweb / main / setmagasinstatus", data: 'id =' + id, format: 'js'  

Comments

Popular posts from this blog

Member with no value in F# -

java - Joda Time Interval Not returning what I expect -

c# - Showing a SelectedItem's Property -