如何在具有 link_to 和 ajax 的表单中触发创建控制器?
How to trigger the create controller within a form with link_to and ajax?
我的控制器在提交时有一个来自触发器的“创建”操作。预期的行为是添加一个 link ,它在触发创建操作和响应的表单内 javascript _tax.html.erb.
实际结果不会触发 create.js.erb javascript 代码..
你明白为什么了吗?
<%= form_for @product, remote: true do |f| %>
<%= f.text_field :name, placeholder: :name %>
<% @product.taxes.each do |rate| %>
<%= render "tax", :f => rate %>
<% end %>
<%= link_to "Get Quote","#", {:quote => true :remote => true, :id => "quote" , :onclick => "$('#new_product').submit()"}%>
<%= f.submit %>
<%= end %>
product_controller.rb
def create
respond_to do |format|
format.html { render action: 'new' }
format.json { render json: @product , status: :created, location: @shipment }
format.js
end
end
create.js.rb
console.log("create.js.erb file");
更新:
我刚刚添加了格式::js,现在 javascript erb 文件显示在浏览器上但未执行,这是发送到服务器的请求:
#<ActionDispatch::Request:0x007fc5aa078038 @env={"CONTENT_LENGTH"=>"608", "CONTENT_TYPE"=>"application/x-www-form-urlencoded", "GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/products.js", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"::1", "REMOTE_HOST"=>"::1", "REQUEST_METHOD"=>"POST", "REQUEST_URI"=>"http://localhost:3000/products.js", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.0.0/2015-04-13)", "HTTP_HOST"=>"localhost:3000", "HTTP_CONNECTION"=>"keep-alive", "HTTP_CACHE_CONTROL"=>"max-age=0", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "HTTP_ORIGIN"=>"http://localhost:3000", "HTTP_UPGRADE_INSECURE_REQUESTS"=>"1", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36", "HTTP_REFERER"=>"http://localhost:3000/products/new", "HTTP_ACCEPT_ENCODING"=>"gzip, deflate", "HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8,he;q=0.6", "HTTP_COOKIE"=>"_casual_shipping_session=MGdWdWZWSDBac2pyVTBZamQ2YXYvK25ZZEFST1V2S20xU0hQT0VjVFY2RkxzdWRzL1Y5a2h1dXp5Y1VPY1NyVy9BeFJCYm82cHhIZG1SMHRScTB2REJCRlBTeGxVWmlHajlDaTIxa2ZZL0t5TUF5ZmRlNDBERWx1ZG42S2xwZnk0bEszMkVKSXNib05qQWR0N2drWTBYYTdKcGZMRktwMm1zWlA1alBsTDkwT1FCRU9zcGxEYVBuMmM4N3lnSVdxOUkwemo3Z1diaGE3YytpcmVQUEV1V2R3YkdJdHBueXJyV3hLdVpVUW9oWjVYcVJFZzg1VmRhYWxFMzM5OHJ3Ly0tSm9aZlRYSUJZTHp4Qnk4SlAxMHRFQT09--91b6b52d6b8b4da085f67f8b7882a49f9f6f3bdd", "rack.version"=>[1, 3], "rack.input"=>#<StringIO:0x007fc5aa039a68>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "rack.hijack?"=>true, "rack.hijack"=>#<Proc:0x007fc5aa039568@/Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:76 (lambda)>, "rack.hijack_io"=>nil, "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/products.js", "ORIGINAL_FULLPATH"=>"/products.js", "ORIGINAL_SCRIPT_NAME"=>"", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x007fc5a3d09f10>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", "action_dispatch.show_exceptions"=>true, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::Logger:0x007fc5a3d20620 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007fc5a3d20508 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x007fc5a3efa068 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007fc5a3d204b8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/Users/guy/proj/casual_shipping/log/development.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fc5a3d20490 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc5a3d203f0>>>>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x007fc5a4265f40 @filters=[#<Proc:0x007fc5a4269ca8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<Proc:0x007fc5a4269a50@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<Proc:0x007fc5a42696b8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<Proc:0x007fc5a426ddf8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<Proc:0x007fc5a426d9c0@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/Users/guy/proj/casual_shipping/">, "action_dispatch.key_generator"=>#<ActiveSupport::CachingKeyGenerator:0x007fc5a3fc1ed8 @key_generator=#<ActiveSupport::KeyGenerator:0x007fc5a3fc1f28 @secret="e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x007fc5a3fc1eb0 @backend={"signed_global_ids64"=>"\xF80{\x81b\x03\xE0)#\xB0G\n:Bo%~\x16\x94\x8A\x19\x1A\xAD\xB5\xD8*x\xCA\xF71b\x9A\xED\xE1\x04\xBB\x81\xCE\x18|\xC2\x11\xBF\xD0B\xE8,\xAF\x1D\x9A\x1D9\x9E7\x8A\xA5\xB4\xCE&\xFA0b\x15\x90", "encrypted cookie64"=>"\xE8\a\x91\x16~\xF3r\xA5\xA6\e\xA8\xC6k\t\xEB\x9FD\xF6\xF1\x06nC\xAF\x8Df\xCA\xFBz\xDEN\xED\xBA\xD2]\x16\x86\x1Ah\xFBz\xEE\xDE\x93\xF7\r\xA7\xD7\xE4\xDD\xC1\xBFS\xF2@\xFA\xB7%\x18\x11\xF7\x0F\xFEhB", "signed encrypted cookie64"=>"2k\x00w\xFD\xE6\xFBy:\xE0L_\xADXTx=\x10\xB1\xF0\xA5\x9C\x0F\x1D\xF3vG\x1C18\x8D\xBD\xA8a\x90*\xB3\xC6\x84\vay\x80^\x84\xC2\xC4#\x86$\x8C\xC4\x03\xC9\xDC>~j\xC9tfUd2"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "ROUTES_70243416821640_SCRIPT_NAME"=>"", "rack.request.form_hash"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product"}, "rack.request.form_vars"=>"utf8=%E2%9C%93&product%5Bfrom_country%5D=US&product%5Bfrom_postal_code%5D=&product%5Bfrom_city%5D=&product%5Bfrom_state%5D=&product%5Bto_country%5D=US&product%5Bto_postal_code%5D=&product%5Bto_city%5D=&product%5Bto_state%5D=&product%5Bname%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Blength%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bwidth%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bheight%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bweight%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bcylinder%5D=0&product%5Bpackages_attributes%5D%5B0%5D%5B_destroy%5D=false&commit=Create+product", "rack.request.form_input"=>#<StringIO:0x007fc5aa039a68>, "action_dispatch.request_id"=>"34cb4288-1906-4d59-a98d-00890271036a", "action_dispatch.remote_ip"=>#<ActionDispatch::RemoteIp::GetIp:0x007fc5aa07b508 @env={...}, @check_ip=true, @proxies=[#<IPAddr: IPv4:127.0.0.1/255.255.255.255>, #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>, #<IPAddr: IPv6:fc00:0000:0000:0000:0000:0000:0000:0000/fe00:0000:0000:0000:0000:0000:0000:0000>, #<IPAddr: IPv4:10.0.0.0/255.0.0.0>, #<IPAddr: IPv4:172.16.0.0/255.240.0.0>, #<IPAddr: IPv4:192.168.0.0/255.255.0.0>]>, "rack.session"=>{}, "rack.session.options"=>{:skip=>true}, "action_dispatch.request.content_type"=>#<Mime::Type:0x007fc5a3de1d70 @synonyms=[], @symbol=:url_encoded_form, @string="application/x-www-form-urlencoded">, "action_dispatch.request.path_parameters"=>{:controller=>"products", :action=>"create", :format=>"js"}, "action_controller.instance"=>#<productsController:0x007fc5aa078150 @_action_has_layout=true, @_routes=nil, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionDispatch::Request:0x007fc5aa078038 ...>, @_response=#<ActionDispatch::Response:0x007fc5aa081ae8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc5aa082c18>, @stream=#<ActionDispatch::Response::Buffer:0x007fc5aa083fa0 @response=#<ActionDispatch::Response:0x007fc5aa081ae8 ...>, @buf=[], @closed=false>, @header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff"}, @status=200, @sending_file=false, @blank=false, @cv=#<MonitorMixin::ConditionVariable:0x007fc5aa083f78 @monitor=#<ActionDispatch::Response:0x007fc5aa081ae8 ...>, @cond=#<ConditionVariable:0x007fc5aa083f50 @waiters={}, @waiters_mutex=#<Mutex:0x007fc5aa083f00>>>, @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil, @request=#<ActionDispatch::Request:0x007fc5aa078038 ...>>, @_env={...}, @_lookup_context=#<ActionView::LookupContext:0x007fc5aa083d98 @details_key=nil, @details={:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}, @skip_default_locale=false, @cache=true, @prefixes=["products", "application"], @rendered_format=nil, @view_paths=#<ActionView::PathSet:0x007fc5aa083d20 @paths=[#<ActionView::OptimizedFileSystemResolver:0x007fc5a45db738 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x007fc5a45db710 @data=#<ActionView::Resolver::Cache::SmallCache:0x007fc5a45db698 @backend={#<ActionView::LookupContext::DetailsKey:0x007fc5aa052a90 @hash=-2255248275316338300>=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01ad70 @backend={"new"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01aca8 @backend={"products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01abb8 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01aac8 @backend={[]=>[app/views/products/new.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019c40 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019b50 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019a60 @backend={}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "application"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018908 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018818 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018728 @backend={[]=>[app/views/layouts/application.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "form"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa021030 @backend={"products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa020f40 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa020e50 @backend={[]=>[app/views/products/_form.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "package_fields"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb678 @backend={""=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb588 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb498 @backend={["f"]=>[app/views/_package_fields.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99c88@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:48 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99b98@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/Users/guy/proj/casual_shipping/app/views">]>, @html_fallback_for_js=true>, @_action_name="create", @_response_body=nil, @marked_for_same_origin_verification=false, @_config={}, @product=#<product id: nil, name: "", from_country: "US", from_city: "", from_state: "", from_postal_code: "", to_country: "US", to_city: "", to_state: "", to_postal_code: "", created_at: nil, updated_at: nil>, @_params={"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}>, "action_dispatch.request.request_parameters"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product"}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}, "action_dispatch.request.formats"=>[#<Mime::Type:0x007fc5a3dda250 @synonyms=["application/javascript", "application/x-javascript"], @symbol=:js, @string="text/javascript">], "action_dispatch.request.flash_hash"=>#<ActionDispatch::Flash::FlashHash:0x007fc5aa09a908 @discard=#<Set: {"success"}>, @flashes={"success"=>["sucessfully created"]}, @now=#<ActionDispatch::Flash::FlashNow:0x007fc5aa09a610 @flash=#<ActionDispatch::Flash::FlashHash:0x007fc5aa09a908 ...>>>, "action_dispatch.cookies"=>#<ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullCookieJar:0x007fc5aa089f90 @key_generator=#<ActiveSupport::CachingKeyGenerator:0x007fc5a3fc1ed8 @key_generator=#<ActiveSupport::KeyGenerator:0x007fc5a3fc1f28 @secret="e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x007fc5a3fc1eb0 @backend={"signed_global_ids64"=>"\xF80{\x81b\x03\xE0)#\xB0G\n:Bo%~\x16\x94\x8A\x19\x1A\xAD\xB5\xD8*x\xCA\xF71b\x9A\xED\xE1\x04\xBB\x81\xCE\x18|\xC2\x11\xBF\xD0B\xE8,\xAF\x1D\x9A\x1D9\x9E7\x8A\xA5\xB4\xCE&\xFA0b\x15\x90", "encrypted cookie64"=>"\xE8\a\x91\x16~\xF3r\xA5\xA6\e\xA8\xC6k\t\xEB\x9FD\xF6\xF1\x06nC\xAF\x8Df\xCA\xFBz\xDEN\xED\xBA\xD2]\x16\x86\x1Ah\xFBz\xEE\xDE\x93\xF7\r\xA7\xD7\xE4\xDD\xC1\xBFS\xF2@\xFA\xB7%\x18\x11\xF7\x0F\xFEhB", "signed encrypted cookie64"=>"2k\x00w\xFD\xE6\xFBy:\xE0L_\xADXTx=\x10\xB1\xF0\xA5\x9C\x0F\x1D\xF3vG\x1C18\x8D\xBD\xA8a\x90*\xB3\xC6\x84\vay\x80^\x84\xC2\xC4#\x86$\x8C\xC4\x03\xC9\xDC>~j\xC9tfUd2"}, @default_proc=nil>>, @set_cookies={"request_method"=>{:value=>"POST", :path=>"/"}}, @delete_cookies={}, @host="localhost", @secure=false, @options={:signed_cookie_salt=>"", :encrypted_cookie_salt=>"", :encrypted_signed_cookie_salt=>"", :secret_token=>nil, :secret_key_base=>nil, :upgrade_legacy_signed_cookies=>false, :serializer=>nil, :digest=>nil}, @cookies={"request_method"=>"POST"}, @committed=false>}, @filtered_parameters={"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method="POST", @remote_ip=nil, @original_fullpath=nil, @fullpath="/products.js", @ip=nil, @uuid=nil>
atghhhhh...3 天的调试,我在 application.html.erb 文件中缺少的是
<%= javascript_include_tag "application" %>
我的控制器在提交时有一个来自触发器的“创建”操作。预期的行为是添加一个 link ,它在触发创建操作和响应的表单内 javascript _tax.html.erb.
实际结果不会触发 create.js.erb javascript 代码.. 你明白为什么了吗?
<%= form_for @product, remote: true do |f| %>
<%= f.text_field :name, placeholder: :name %>
<% @product.taxes.each do |rate| %>
<%= render "tax", :f => rate %>
<% end %>
<%= link_to "Get Quote","#", {:quote => true :remote => true, :id => "quote" , :onclick => "$('#new_product').submit()"}%>
<%= f.submit %>
<%= end %>
product_controller.rb
def create
respond_to do |format|
format.html { render action: 'new' }
format.json { render json: @product , status: :created, location: @shipment }
format.js
end
end
create.js.rb
console.log("create.js.erb file");
更新:
我刚刚添加了格式::js,现在 javascript erb 文件显示在浏览器上但未执行,这是发送到服务器的请求:
#<ActionDispatch::Request:0x007fc5aa078038 @env={"CONTENT_LENGTH"=>"608", "CONTENT_TYPE"=>"application/x-www-form-urlencoded", "GATEWAY_INTERFACE"=>"CGI/1.1", "PATH_INFO"=>"/products.js", "QUERY_STRING"=>"", "REMOTE_ADDR"=>"::1", "REMOTE_HOST"=>"::1", "REQUEST_METHOD"=>"POST", "REQUEST_URI"=>"http://localhost:3000/products.js", "SCRIPT_NAME"=>"", "SERVER_NAME"=>"localhost", "SERVER_PORT"=>"3000", "SERVER_PROTOCOL"=>"HTTP/1.1", "SERVER_SOFTWARE"=>"WEBrick/1.3.1 (Ruby/2.0.0/2015-04-13)", "HTTP_HOST"=>"localhost:3000", "HTTP_CONNECTION"=>"keep-alive", "HTTP_CACHE_CONTROL"=>"max-age=0", "HTTP_ACCEPT"=>"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8", "HTTP_ORIGIN"=>"http://localhost:3000", "HTTP_UPGRADE_INSECURE_REQUESTS"=>"1", "HTTP_USER_AGENT"=>"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.106 Safari/537.36", "HTTP_REFERER"=>"http://localhost:3000/products/new", "HTTP_ACCEPT_ENCODING"=>"gzip, deflate", "HTTP_ACCEPT_LANGUAGE"=>"en-US,en;q=0.8,he;q=0.6", "HTTP_COOKIE"=>"_casual_shipping_session=MGdWdWZWSDBac2pyVTBZamQ2YXYvK25ZZEFST1V2S20xU0hQT0VjVFY2RkxzdWRzL1Y5a2h1dXp5Y1VPY1NyVy9BeFJCYm82cHhIZG1SMHRScTB2REJCRlBTeGxVWmlHajlDaTIxa2ZZL0t5TUF5ZmRlNDBERWx1ZG42S2xwZnk0bEszMkVKSXNib05qQWR0N2drWTBYYTdKcGZMRktwMm1zWlA1alBsTDkwT1FCRU9zcGxEYVBuMmM4N3lnSVdxOUkwemo3Z1diaGE3YytpcmVQUEV1V2R3YkdJdHBueXJyV3hLdVpVUW9oWjVYcVJFZzg1VmRhYWxFMzM5OHJ3Ly0tSm9aZlRYSUJZTHp4Qnk4SlAxMHRFQT09--91b6b52d6b8b4da085f67f8b7882a49f9f6f3bdd", "rack.version"=>[1, 3], "rack.input"=>#<StringIO:0x007fc5aa039a68>, "rack.errors"=>#<IO:<STDERR>>, "rack.multithread"=>false, "rack.multiprocess"=>false, "rack.run_once"=>false, "rack.url_scheme"=>"http", "rack.hijack?"=>true, "rack.hijack"=>#<Proc:0x007fc5aa039568@/Library/Ruby/Gems/2.0.0/gems/rack-1.6.4/lib/rack/handler/webrick.rb:76 (lambda)>, "rack.hijack_io"=>nil, "HTTP_VERSION"=>"HTTP/1.1", "REQUEST_PATH"=>"/products.js", "ORIGINAL_FULLPATH"=>"/products.js", "ORIGINAL_SCRIPT_NAME"=>"", "action_dispatch.routes"=>#<ActionDispatch::Routing::RouteSet:0x007fc5a3d09f10>, "action_dispatch.parameter_filter"=>[:password], "action_dispatch.redirect_filter"=>[], "action_dispatch.secret_token"=>nil, "action_dispatch.secret_key_base"=>"e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", "action_dispatch.show_exceptions"=>true, "action_dispatch.show_detailed_exceptions"=>true, "action_dispatch.logger"=>#<ActiveSupport::Logger:0x007fc5a3d20620 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007fc5a3d20508 @datetime_format=nil>, @formatter=#<ActiveSupport::Logger::SimpleFormatter:0x007fc5a3efa068 @datetime_format=nil>, @logdev=#<Logger::LogDevice:0x007fc5a3d204b8 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<File:/Users/guy/proj/casual_shipping/log/development.log>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fc5a3d20490 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc5a3d203f0>>>>, "action_dispatch.backtrace_cleaner"=>#<Rails::BacktraceCleaner:0x007fc5a4265f40 @filters=[#<Proc:0x007fc5a4269ca8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:14>, #<Proc:0x007fc5a4269a50@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:15>, #<Proc:0x007fc5a42696b8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:16>, #<Proc:0x007fc5a426ddf8@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:29>], @silencers=[#<Proc:0x007fc5a426d9c0@/Library/Ruby/Gems/2.0.0/gems/railties-4.2.5/lib/rails/backtrace_cleaner.rb:19>], @root="/Users/guy/proj/casual_shipping/">, "action_dispatch.key_generator"=>#<ActiveSupport::CachingKeyGenerator:0x007fc5a3fc1ed8 @key_generator=#<ActiveSupport::KeyGenerator:0x007fc5a3fc1f28 @secret="e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x007fc5a3fc1eb0 @backend={"signed_global_ids64"=>"\xF80{\x81b\x03\xE0)#\xB0G\n:Bo%~\x16\x94\x8A\x19\x1A\xAD\xB5\xD8*x\xCA\xF71b\x9A\xED\xE1\x04\xBB\x81\xCE\x18|\xC2\x11\xBF\xD0B\xE8,\xAF\x1D\x9A\x1D9\x9E7\x8A\xA5\xB4\xCE&\xFA0b\x15\x90", "encrypted cookie64"=>"\xE8\a\x91\x16~\xF3r\xA5\xA6\e\xA8\xC6k\t\xEB\x9FD\xF6\xF1\x06nC\xAF\x8Df\xCA\xFBz\xDEN\xED\xBA\xD2]\x16\x86\x1Ah\xFBz\xEE\xDE\x93\xF7\r\xA7\xD7\xE4\xDD\xC1\xBFS\xF2@\xFA\xB7%\x18\x11\xF7\x0F\xFEhB", "signed encrypted cookie64"=>"2k\x00w\xFD\xE6\xFBy:\xE0L_\xADXTx=\x10\xB1\xF0\xA5\x9C\x0F\x1D\xF3vG\x1C18\x8D\xBD\xA8a\x90*\xB3\xC6\x84\vay\x80^\x84\xC2\xC4#\x86$\x8C\xC4\x03\xC9\xDC>~j\xC9tfUd2"}, @default_proc=nil>>, "action_dispatch.http_auth_salt"=>"http authentication", "action_dispatch.signed_cookie_salt"=>"signed cookie", "action_dispatch.encrypted_cookie_salt"=>"encrypted cookie", "action_dispatch.encrypted_signed_cookie_salt"=>"signed encrypted cookie", "action_dispatch.cookies_serializer"=>:json, "action_dispatch.cookies_digest"=>nil, "ROUTES_70243416821640_SCRIPT_NAME"=>"", "rack.request.form_hash"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product"}, "rack.request.form_vars"=>"utf8=%E2%9C%93&product%5Bfrom_country%5D=US&product%5Bfrom_postal_code%5D=&product%5Bfrom_city%5D=&product%5Bfrom_state%5D=&product%5Bto_country%5D=US&product%5Bto_postal_code%5D=&product%5Bto_city%5D=&product%5Bto_state%5D=&product%5Bname%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Blength%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bwidth%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bheight%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bweight%5D=&product%5Bpackages_attributes%5D%5B0%5D%5Bcylinder%5D=0&product%5Bpackages_attributes%5D%5B0%5D%5B_destroy%5D=false&commit=Create+product", "rack.request.form_input"=>#<StringIO:0x007fc5aa039a68>, "action_dispatch.request_id"=>"34cb4288-1906-4d59-a98d-00890271036a", "action_dispatch.remote_ip"=>#<ActionDispatch::RemoteIp::GetIp:0x007fc5aa07b508 @env={...}, @check_ip=true, @proxies=[#<IPAddr: IPv4:127.0.0.1/255.255.255.255>, #<IPAddr: IPv6:0000:0000:0000:0000:0000:0000:0000:0001/ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff>, #<IPAddr: IPv6:fc00:0000:0000:0000:0000:0000:0000:0000/fe00:0000:0000:0000:0000:0000:0000:0000>, #<IPAddr: IPv4:10.0.0.0/255.0.0.0>, #<IPAddr: IPv4:172.16.0.0/255.240.0.0>, #<IPAddr: IPv4:192.168.0.0/255.255.0.0>]>, "rack.session"=>{}, "rack.session.options"=>{:skip=>true}, "action_dispatch.request.content_type"=>#<Mime::Type:0x007fc5a3de1d70 @synonyms=[], @symbol=:url_encoded_form, @string="application/x-www-form-urlencoded">, "action_dispatch.request.path_parameters"=>{:controller=>"products", :action=>"create", :format=>"js"}, "action_controller.instance"=>#<productsController:0x007fc5aa078150 @_action_has_layout=true, @_routes=nil, @_headers={"Content-Type"=>"text/html"}, @_status=200, @_request=#<ActionDispatch::Request:0x007fc5aa078038 ...>, @_response=#<ActionDispatch::Response:0x007fc5aa081ae8 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fc5aa082c18>, @stream=#<ActionDispatch::Response::Buffer:0x007fc5aa083fa0 @response=#<ActionDispatch::Response:0x007fc5aa081ae8 ...>, @buf=[], @closed=false>, @header={"X-Frame-Options"=>"SAMEORIGIN", "X-XSS-Protection"=>"1; mode=block", "X-Content-Type-Options"=>"nosniff"}, @status=200, @sending_file=false, @blank=false, @cv=#<MonitorMixin::ConditionVariable:0x007fc5aa083f78 @monitor=#<ActionDispatch::Response:0x007fc5aa081ae8 ...>, @cond=#<ConditionVariable:0x007fc5aa083f50 @waiters={}, @waiters_mutex=#<Mutex:0x007fc5aa083f00>>>, @committed=false, @sending=false, @sent=false, @content_type=nil, @charset=nil, @cache_control={}, @etag=nil, @request=#<ActionDispatch::Request:0x007fc5aa078038 ...>>, @_env={...}, @_lookup_context=#<ActionView::LookupContext:0x007fc5aa083d98 @details_key=nil, @details={:locale=>[:en], :formats=>[:js, :html], :variants=>[], :handlers=>[:erb, :builder, :raw, :ruby, :coffee, :jbuilder]}, @skip_default_locale=false, @cache=true, @prefixes=["products", "application"], @rendered_format=nil, @view_paths=#<ActionView::PathSet:0x007fc5aa083d20 @paths=[#<ActionView::OptimizedFileSystemResolver:0x007fc5a45db738 @pattern=":prefix/:action{.:locale,}{.:formats,}{+:variants,}{.:handlers,}", @cache=#<ActionView::Resolver::Cache:0x007fc5a45db710 @data=#<ActionView::Resolver::Cache::SmallCache:0x007fc5a45db698 @backend={#<ActionView::LookupContext::DetailsKey:0x007fc5aa052a90 @hash=-2255248275316338300>=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01ad70 @backend={"new"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01aca8 @backend={"products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01abb8 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa01aac8 @backend={[]=>[app/views/products/new.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019c40 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019b50 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa019a60 @backend={}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "application"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018908 @backend={"layouts"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018818 @backend={false=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa018728 @backend={[]=>[app/views/layouts/application.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "form"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa021030 @backend={"products"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa020f40 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa020e50 @backend={[]=>[app/views/products/_form.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>, "package_fields"=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb678 @backend={""=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb588 @backend={true=>#<ActionView::Resolver::Cache::SmallCache:0x007fc5aa0eb498 @backend={["f"]=>[app/views/_package_fields.html.erb]}, @default_proc=nil>}, @default_proc=#<Proc:0x007fc5a3c99fd0@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:46 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99e18@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:47 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99c88@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:48 (lambda)>>}, @default_proc=#<Proc:0x007fc5a3c99b98@/Library/Ruby/Gems/2.0.0/gems/actionview-4.2.5/lib/action_view/template/resolver.rb:49 (lambda)>>>, @path="/Users/guy/proj/casual_shipping/app/views">]>, @html_fallback_for_js=true>, @_action_name="create", @_response_body=nil, @marked_for_same_origin_verification=false, @_config={}, @product=#<product id: nil, name: "", from_country: "US", from_city: "", from_state: "", from_postal_code: "", to_country: "US", to_city: "", to_state: "", to_postal_code: "", created_at: nil, updated_at: nil>, @_params={"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}>, "action_dispatch.request.request_parameters"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product"}, "rack.request.query_string"=>"", "rack.request.query_hash"=>{}, "action_dispatch.request.query_parameters"=>{}, "action_dispatch.request.parameters"=>{"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}, "action_dispatch.request.formats"=>[#<Mime::Type:0x007fc5a3dda250 @synonyms=["application/javascript", "application/x-javascript"], @symbol=:js, @string="text/javascript">], "action_dispatch.request.flash_hash"=>#<ActionDispatch::Flash::FlashHash:0x007fc5aa09a908 @discard=#<Set: {"success"}>, @flashes={"success"=>["sucessfully created"]}, @now=#<ActionDispatch::Flash::FlashNow:0x007fc5aa09a610 @flash=#<ActionDispatch::Flash::FlashHash:0x007fc5aa09a908 ...>>>, "action_dispatch.cookies"=>#<ActionController::RequestForgeryProtection::ProtectionMethods::NullSession::NullCookieJar:0x007fc5aa089f90 @key_generator=#<ActiveSupport::CachingKeyGenerator:0x007fc5a3fc1ed8 @key_generator=#<ActiveSupport::KeyGenerator:0x007fc5a3fc1f28 @secret="e2016495c30abfd9159d6a4311caaf65e31c0fda19ba308e2f2a24ab41c6d22f3aa81bfead82b070fc886add05702bc4bbd50230239ddc17d73f0a673cf85720", @iterations=1000>, @cache_keys=#<ThreadSafe::Cache:0x007fc5a3fc1eb0 @backend={"signed_global_ids64"=>"\xF80{\x81b\x03\xE0)#\xB0G\n:Bo%~\x16\x94\x8A\x19\x1A\xAD\xB5\xD8*x\xCA\xF71b\x9A\xED\xE1\x04\xBB\x81\xCE\x18|\xC2\x11\xBF\xD0B\xE8,\xAF\x1D\x9A\x1D9\x9E7\x8A\xA5\xB4\xCE&\xFA0b\x15\x90", "encrypted cookie64"=>"\xE8\a\x91\x16~\xF3r\xA5\xA6\e\xA8\xC6k\t\xEB\x9FD\xF6\xF1\x06nC\xAF\x8Df\xCA\xFBz\xDEN\xED\xBA\xD2]\x16\x86\x1Ah\xFBz\xEE\xDE\x93\xF7\r\xA7\xD7\xE4\xDD\xC1\xBFS\xF2@\xFA\xB7%\x18\x11\xF7\x0F\xFEhB", "signed encrypted cookie64"=>"2k\x00w\xFD\xE6\xFBy:\xE0L_\xADXTx=\x10\xB1\xF0\xA5\x9C\x0F\x1D\xF3vG\x1C18\x8D\xBD\xA8a\x90*\xB3\xC6\x84\vay\x80^\x84\xC2\xC4#\x86$\x8C\xC4\x03\xC9\xDC>~j\xC9tfUd2"}, @default_proc=nil>>, @set_cookies={"request_method"=>{:value=>"POST", :path=>"/"}}, @delete_cookies={}, @host="localhost", @secure=false, @options={:signed_cookie_salt=>"", :encrypted_cookie_salt=>"", :encrypted_signed_cookie_salt=>"", :secret_token=>nil, :secret_key_base=>nil, :upgrade_legacy_signed_cookies=>false, :serializer=>nil, :digest=>nil}, @cookies={"request_method"=>"POST"}, @committed=false>}, @filtered_parameters={"utf8"=>"✓", "product"=>{"from_country"=>"US", "from_postal_code"=>"", "from_city"=>"", "from_state"=>"", "to_country"=>"US", "to_postal_code"=>"", "to_city"=>"", "to_state"=>"", "name"=>"", "packages_attributes"=>{"0"=>{"length"=>"", "width"=>"", "height"=>"", "weight"=>"", "cylinder"=>"0", "_destroy"=>"false"}}}, "commit"=>"Create product", "controller"=>"products", "action"=>"create", "format"=>"js"}, @filtered_env=nil, @filtered_path=nil, @protocol=nil, @port=nil, @method=nil, @request_method="POST", @remote_ip=nil, @original_fullpath=nil, @fullpath="/products.js", @ip=nil, @uuid=nil>
atghhhhh...3 天的调试,我在 application.html.erb 文件中缺少的是
<%= javascript_include_tag "application" %>