Jquery_ujs.js 404

I am getting this annoying error which relates to jquery_ujs.js not
being served. Any clues?

This is the site link:
http://test.kopy.com.br/home/index

GET http://test.kopy.com.br/assets/jquery_ujs.js?body=1 404 (Not Found)
index:11
GET http://ads.panoramtech.net/loader.js?client=tac
net::ERR_BLOCKED_BY_CLIENT rev.js:4
Error in event handler for (unknown): Cannot read property ‘state’ of
null
Stack trace: TypeError: Cannot read property ‘state’ of null
at CSRecorder.onQueryStateCompleted
(chrome-extension://cplklnmnlbnpmjogncfgfijoopmnlemp/content_scripts/recorder.js:43:13)
at messageListener (extensions::messaging:340:9)
at Function.target.(anonymous function)
(extensions::SafeBuiltins:19:14)
at EventImpl.dispatchToListener (extensions::event_bindings:395:22)
at Function.target.(anonymous function)
(extensions::SafeBuiltins:19:14)
at publicClass.(anonymous function) [as dispatchToListener]
(extensions::utils:69:26)
at EventImpl.dispatch_ (extensions::event_bindings:378:35)
at EventImpl.dispatch (extensions::event_bindings:401:17)
at Function.target.(anonymous function)
(extensions::SafeBuiltins:19:14)
at publicClass.(anonymous function) [as dispatch]
(extensions::utils:69:26) extensions::event_bindings:383
event.returnValue is deprecated. Please use the standard
event.preventDefault() instead. jquery.js:75

This is my application.rb
// This is a manifest file that’ll be compiled into application.js,
which will include all the files
// listed below.
//
// Any JavaScript/Coffee file within this directory,
lib/assets/javascripts, vendor/assets/javascripts,
// or vendor/assets/javascripts of plugins, if any, can be referenced
here using a relative path.
//
// It’s not advisable to add code directly here, but if you do, it’ll
appear at the bottom of the
// compiled file.
//
// Read Sprockets README
(https://github.com/sstephenson/sprockets#sprockets-directives) for
details
// about supported directives.
//
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require_tree .

// **************** this is my production *************************
Kopy2::Application.configure do

Settings specified here will take precedence over those in

config/application.rb

Code is not reloaded between requests

config.cache_classes = true

Full error reports are disabled and caching is turned on

config.consider_all_requests_local = false
config.action_controller.perform_caching = true

Disable Rails’s static asset server (Apache or nginx will already do

this)
config.serve_static_assets = false

Compress JavaScripts and CSS

config.assets.compress = true

Don’t fallback to assets pipeline if a precompiled asset is missed

config.assets.compile = true

Generate digests for assets URLs

config.assets.digest = true

Defaults to nil and saved in location specified by

config.assets.prefix

config.assets.manifest = YOUR_PATH

Specifies the header that your server uses for sending files

config.action_dispatch.x_sendfile_header = “X-Sendfile” # for apache

config.action_dispatch.x_sendfile_header = ‘X-Accel-Redirect’ # for
nginx

Force all access to the app over SSL, use Strict-Transport-Security,

and use secure cookies.

config.force_ssl = true

See everything in the log (default is :info)

config.log_level = :debug

Prepend all log lines with the following tags

config.log_tags = [ :subdomain, :uuid ]

Use a different logger for distributed setups

config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)

Use a different cache store in production

config.cache_store = :mem_cache_store

Enable serving of images, stylesheets, and JavaScripts from an asset

server

config.action_controller.asset_host = “http://assets.example.com

Precompile additional assets (application.js, application.css, and

all non-JS/CSS are already added)
config.assets.precompile += %w[*.js *.css *.png *.jpg *.jpeg *.gif]

Disable delivery errors, bad email addresses will be ignored

config.action_mailer.raise_delivery_errors = false

Enable threaded mode

config.threadsafe!

Enable locale fallbacks for I18n (makes lookups for any locale fall

back to

the I18n.default_locale when a translation can not be found)

config.i18n.fallbacks = true

Send deprecation notices to registered listeners

config.active_support.deprecation = :notify

Log the query plan for queries taking more than this (works

with SQLite, MySQL, and PostgreSQL)

config.active_record.auto_explain_threshold_in_seconds = 0.5

end

// **************** This is my application.html.erb ***********

Kopy <%= stylesheet_link_tag "application", :media => "all" %> <%= javascript_include_tag 'application' %> <%= csrf_meta_tags %> sdfsdsds

<%= yield %>

// **************** This is my home.html.erb *********************

Admin Kopy <%= csrf_meta_tags %> <%= stylesheet_link_tag("home") %>
<%= image_tag("logo.png") %>
  • <%= link_to "Home", :controller => "home", :action => "index" %>
  • <%= link_to "Bureaus", :controller => "bureaus", :action => "index" %>
  • <%= RUBY_VERSION%> - <%= Rails.env %> <% if !session[:user_id].nil? %>
  • <%= link_to "Minha Conta", :controller => "my_account", :action => "index" %>
  • <% end %>
  • <%= link_to "Registrar", :controller => "user_registration", :action => "new" %>
  • <% if !session[:user_id].nil? %> <%= link_to "Logout", :controller => "access", :action => "logout" %> <% else %> <%= link_to "Login", :controller => "access", :action => "login" %> <% end %>
  • <%= session[:username] %>
<%= yield %>
footer

On Friday, April 25, 2014 11:22:23 PM UTC-4, Ruby-Forum.com User wrote:

net::ERR_BLOCKED_BY_CLIENT rev.js:4
at Function.target.(anonymous function)
event.preventDefault() instead. jquery.js:75
//
//= require jquery_ujs

Specifies the header that your server uses for sending files

server

config.threadsafe!

with SQLite, MySQL, and PostgreSQL)

<%= csrf_meta_tags %>

src=“http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js”>

  <ul class="sub-menu">
    <% end %>
    </li>


Posted via http://www.ruby-forum.com/.

need to see the controller code. Basically, it’s executing
home.html.erb
as a layout (it’s not using the application.html.erb). Because of this,
the following statement is missed:

<%= javascript_include_tag ‘application’ %>

I may have a better idea of exactly what’s happening when I see the
controller code. I’m also assuming that you have gem ‘jquery-rails’ in
your Gemfile.

Also, I would recommend you read the following guide as you aren’t
properly
using layouts and templates:

http://edgeguides.rubyonrails.org/layouts_and_rendering.html

On Sunday, April 27, 2014 5:12:41 PM UTC-4, Ruby-Forum.com User wrote:

def index

end
  end

event.preventDefault() instead. jquery.js:75

I may have a better idea of exactly what’s happening when I see the
Posted via http://www.ruby-forum.com/.

The statement causing the problem is:

layout ‘home’

Rails uses layouts and templates in its view rendering system (plus
other
things, but let’s start with that). The default layout is
application.html.erb. With the above statement, you’ve overridden the
default. I’m assuming that you were having issues because the default
template for this action would be index.html.erb and you wanted it to be
home.html.erb. You would accomplish that by 1) get rid of the layout
statement and 2) insert the following statement at the end of the index
action:

render template: ‘home’

You will have some other issues when you do this. The layout is
intended
to be the overall framework and, at a minimum, includes the following:

. .

The contents of the template (home.html.erb) will be inserted where you
see
the word yield in the application layout. In your case, you’ve defined
the
doctype and html tag in both the application layout and the template
which
will result in the html tag being defined twice which is invalid html.
Again, I refer you to the guide linked above.

You’re going to have a few other issues. You are separately loading the
jquery and jquery-ui files from google. Once you have this working
correctly, that will result in those files being loaded twice and
potentially two different versions: the rails version and the version
you’re loading from google.

I also encourage you to go through a good tutorial such as
railstutorial.org. You seem to have a pretty good foundation in ruby,
so I
don’t think it would take you long to go through the tutorial. You are
doing a lot of things in your controller that 1) you don’t need to do if
you work with Rails conventions and 2) some of them belong in a model.

Thanks for looking at it. There goes the home controller bellow. And yes
I am using gem ‘jquery-rails’. What is funny is that in my development
environment locally it is working. This error is from an passenger/nginx
installation.
Rod

class HomeController < ApplicationController
layout ‘home’

def index

#sleep 1.5
#@shops = Shop.order("name").page(params[:page])
@shops = Shop.order('created_at desc').paginate(:per_page => 2, 

:page => params[:page])
#User.paginate(:page => params[:page])

#query = Product.joins(:category)
query = Shop.joins(:product_options).where("product_id=1")
sql = query.to_sql

sql = "SELECT * from products"
r = ActiveRecord::Base.connection.execute(sql)
@query = r = r

zip= params[:zip]
@foundZip=false

if (!zip.nil? && !zip.blank?)
  zip = zip.gsub('.','')
  gc = GeoCity.find_by_ZIP(zip)
end

if (!gc.nil? && zip!=nil && !zip.blank?) # found zip
  @foundZip=true
end

  if request.xhr?
    respond_to do |format|
      format.html
      format.js {render 'index' }
    end
  end

end
end

mike2r wrote in post #1144230:

On Friday, April 25, 2014 11:22:23 PM UTC-4, Ruby-Forum.com User wrote:

net::ERR_BLOCKED_BY_CLIENT rev.js:4
at Function.target.(anonymous function)
event.preventDefault() instead. jquery.js:75
//
//= require jquery_ujs

Specifies the header that your server uses for sending files

server

config.threadsafe!

with SQLite, MySQL, and PostgreSQL)

<%= csrf_meta_tags %>

src=“http://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js”>

  <ul class="sub-menu">
    <% end %>
    </li>


Posted via http://www.ruby-forum.com/.

need to see the controller code. Basically, it’s executing
home.html.erb
as a layout (it’s not using the application.html.erb). Because of this,
the following statement is missed:

<%= javascript_include_tag ‘application’ %>

I may have a better idea of exactly what’s happening when I see the
controller code. I’m also assuming that you have gem ‘jquery-rails’ in
your Gemfile.

Also, I would recommend you read the following guide as you aren’t
properly
using layouts and templates:

http://edgeguides.rubyonrails.org/layouts_and_rendering.html

On Monday, April 28, 2014 8:32:17 PM UTC-4, Ruby-Forum.com User wrote:

This for me is the hard part. I am still at the beginning of the curve,
mike2r wrote in post #1144331:

template for this action would be index.html.erb and you wanted it to be

will result in the html tag being defined twice which is invalid html. so I don't think it would take you long to go through the tutorial. You are doing a lot of things in your controller that 1) you don't need to do if you work with Rails conventions and 2) some of them belong in a model.


Posted via http://www.ruby-forum.com/.

There’s generally three levels of testing in Rails:

  1. Unit testing: this is part of the Rails architecture and doesn’t
    depend
    on a browser. I use rspec/capybara, others use the standard test unit
    supplied with Rails, etc. This is basically automated testing and does
    a
    very good job of testing controllers/models to insure the right things
    are
    happening with respect to information produced (or not produced),
    retrieved
    and saved correctly, etc.

  2. Visual testing which is testing in the browser. When you’re writing
    views, for example, it’s pretty much necessary to see things in a
    browser.
    In this case, I always test in development mode because changes you
    make
    are automatically reflected on a refresh. This is accomplished by
    having
    sprockets and the pipeline live. In production, everything has to be
    pre-compiled and that would significantly slow development time.

  3. Once you have developed the piece or application that you are now
    ready
    to show the client/user, you should test it in the nginx/passenger
    production environment (or whatever environment the application will be
    running in in production). As you have seen above, things can happen
    and
    you should always test this before releasing a piece of your work to be
    reviewed.

I should note you can use nginx/passenger and run it in the development
environment. I sometimes do this, sometimes I just use WEBrick (rails
server).

This is just my opinion, there a lot of different ways to do this but
however you do it, and whatever tools best fit you, it is important that
you test.

The railstutorial.org I referred to in the above posts is free and the
tutorial largely focuses on the rails architecture and models. It takes
you through the construction of a basic twitter-like site step by step,
explaining the concepts as you go. I think there’s one chapter on basic
ruby you could probably skip.

mike

thank you Mike.

Good that you pointed out railstutorial.org. I just checked and Michael
Hartl has updated the Learn Rails by Example to version 4. There is a
free version here to read online:
http://www.railstutorial.org/book/beginning

Thank you very much, It looks like you’re right. All these problems
began to occur after I moved the app to production using
passenger/nginx. I used google version because that was the last
version. I did not know this was being included twice by jquery_ujs.js.
In fact, I was able get rid of some of the error by doing some changes
after your suggestion.

To tell you the truth, the problem is not so much programming but
understanding the concepts of about rails architecture and its modules.
This for me is the hard part. I am still at the beginning of the curve,
but I hope with your suggestion and I will get there.

One more thing:

Do you recommend to testing locally with nginx my rails app? I believe
it will bring the closest scenario to the one I am using i production,
specially if I can debug to better understand the errors.

Rod

mike2r wrote in post #1144331:

On Sunday, April 27, 2014 5:12:41 PM UTC-4, Ruby-Forum.com User wrote:

def index

end
  end

event.preventDefault() instead. jquery.js:75

I may have a better idea of exactly what’s happening when I see the
Posted via http://www.ruby-forum.com/.

The statement causing the problem is:

layout ‘home’

Rails uses layouts and templates in its view rendering system (plus
other
things, but let’s start with that). The default layout is
application.html.erb. With the above statement, you’ve overridden the
default. I’m assuming that you were having issues because the default
template for this action would be index.html.erb and you wanted it to be
home.html.erb. You would accomplish that by 1) get rid of the layout
statement and 2) insert the following statement at the end of the index
action:

render template: ‘home’

You will have some other issues when you do this. The layout is
intended
to be the overall framework and, at a minimum, includes the following:

. .

The contents of the template (home.html.erb) will be inserted where you
see
the word yield in the application layout. In your case, you’ve defined
the
doctype and html tag in both the application layout and the template
which
will result in the html tag being defined twice which is invalid html.
Again, I refer you to the guide linked above.

You’re going to have a few other issues. You are separately loading the
jquery and jquery-ui files from google. Once you have this working
correctly, that will result in those files being loaded twice and
potentially two different versions: the rails version and the version
you’re loading from google.

I also encourage you to go through a good tutorial such as
railstutorial.org. You seem to have a pretty good foundation in ruby,
so I
don’t think it would take you long to go through the tutorial. You are
doing a lot of things in your controller that 1) you don’t need to do if
you work with Rails conventions and 2) some of them belong in a model.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs