RoR, Sizzle Uncaught Error: Syntax error, unrecognized expression: /sv/priser - ruby-on-rails

The error
jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:1464 Uncaught Error: Syntax error, unrecognized expression: /sv/priser
at Function.Sizzle.error (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:1464)
at Sizzle.tokenize (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:2121)
at Sizzle.select (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:2542)
at Function.Sizzle [as find] (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:865)
at jQuery.fn.init.find (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:2788)
at new jQuery.fn.init (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:2905)
at jQuery (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:76)
at HTMLAnchorElement.<anonymous> (kontakt:50)
at HTMLAnchorElement.dispatch (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:4733)
at HTMLAnchorElement.elemData.handle (jquery.self-977e28a4e7fded7698789e394a585c6339d54c0ad1537f498a40d2800098a521.js?body=1:4545)
Getting this error when clicking on a to_link tag in RoR v.5.2 (Ruby v2.5)
The link works, and takes me to the targeted html.erb file. I can't find any solution that has worked.
The tag the error occurs for all tags like this, this one is just an example.
<%= link_to 'Prices', en_prices_path, :class => "page-scroll", id: 'prices' %>
My routes
Rails.application.routes.draw do
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
namespace :en do
get 'index' => 'pages#index', as: 'home'
get 'prices' => 'pages#prices'
get 'about' => 'pages#about'
get 'contact' => 'pages#contact'
end
namespace :sv do
root 'pages#index', as: 'home'
get 'priser' => 'pages#priser'
get 'om' => 'pages#om'
get 'kontakt' => 'pages#kontakt'
end
get '*path' => redirect('/sv')
end
Its noteworthy to mention that the link exists in a partial _nav file that that is being rendered into an index or contact.html.erb file amongst others, that is then being rendered into the application.html.erb file.
I hear talk about jquery complaining about bad selectors, which makes me believe the paths (for example sv_priser_path) the router gives me is bad (it gives me /sv/priser). Can i edit them perhaps? Would that stop the error from happening? I tried parsing them with
$($.parseHTML(sv_priser_path)[1]
but that i didnt get that to work either. Didnt get a replace script to work either to remove the slash.

Related

Running minitest controller get ActionController::UrlGenerationError: No route matches

I know, that with this topic more questions asket, but i don't found what i need.
Currently i'm updating rails app from 3.2.13 to 4.2.0 and after upgrading rails naturally fails tests. These tests are passed in 3.2.13
So, i have this route:
get '/catalogs/:article_id/get_applicability_by_brand/:brand_id', :to => 'catalogs#get_applicability_by_brand', constrains: { format: 'js' }, as: :catalog_get_applicability_by_brand
Result of rake routes like this:
catalog_get_applicability_by_brand GET /catalogs/:article_id/get_applicability_by_brand/:brand_id(.:format) catalogs#get_applicability_by_brand {:constrains=>{:format=>"js"}}
Controller action, it only render js.erb template:
def get_applicability_by_brand
#applicability = CatalogAccess::TecDoc.get_applicability_by_brand(params[:article_id], params[:brand_id])
end
Minitest controller test:
def test_get_applicability_by_brand_action
expected_applicability = [
{ 'model_name' => 'Model 1',
'name' => 'fake name',
'year_of_construct_from' => '2000',
'year_of_construct_to' => '2010',
'construction_type' => 'fake type' },
{ 'model_name' => 'Model 1',
'name' => 'fake name 2',
'year_of_construct_from' => '1991',
'year_of_construct_to' => '2005',
'construction_type' => 'fake type' }
]
CatalogAccess::TecDoc.expects(:get_applicability_by_brand).with('12', '23').returns expected_applicability
xhr :get, :get_applicability_by_brand, :article_id => '12', :brand_id => '23', :format => "js"
assert_response 200
assert_template 'get_applicability_by_brand'
assert_template :partial => '_tecdoc2_applicability'
end
Test error message is:
ActionController::UrlGenerationError: ActionController::UrlGenerationError: No route matches {:action=>"get_applicability_by_brand", :article_id=>"12", :brand_id=>"23", :controller=>"catalogs", :format=>"js"}
I found that if append to my test option 'use_route', it will be pass, but get warning that seems not good solution
xhr :get, :get_applicability_by_brand, :article_id => '12', :brand_id => '23', :format => "js", :use_route => 'catalogs'
Warning message:
DEPRECATION WARNING: You are trying to generate the URL for a named route called "catalogs" but no such route was found. In the future, this will result in an `ActionController::UrlGenerationError` exception. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
DEPRECATION WARNING: Passing the `use_route` option in functional tests are deprecated. Support for this option in the `process` method (and the related `get`, `head`, `post`, `patch`, `put` and `delete` helpers) will be removed in the next version without replacement. Functional tests are essentially unit tests for controllers and they should not require knowledge to how the application's routes are configured. Instead, you should explicitly pass the appropiate params to the `process` method. Previously the engines guide also contained an incorrect example that recommended using this option to test an engine's controllers within the dummy application. That recommendation was incorrect and has since been corrected. Instead, you should override the `#routes` variable in the test case with `Foo::Engine.routes`. See the updated engines guide for details. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
DEPRECATION WARNING: You are trying to generate the URL for a named route called "catalogs" but no such route was found. In the future, this will result in an `ActionController::UrlGenerationError` exception. (called from test_get_applicability_by_brand_action at /home/sdilshod/webapp/ps_base/apps/www/test/controllers/catalogs_controller_test.rb:627)
Advise me please correct solution.
I'll hope your help, thanks!

Rails Engine not routing in webpage

I am trying to mount a rails engine piggybak_paypal.
Inside my application's config/routes.rb file I add
mount PiggybakPaypal::Engine => '/paypal', :as => 'piggybak_paypal'
and the engines route is like this
PiggybakPaypal::Engine.routes.draw do
get "/express" => "paypal#express", :as => :paypal_express
get "/process" => "paypal#process_express", :as => :paypal_process
end
When I try rake routes the route of the engine is showing correctly
Routes for PiggybakPaypal::Engine:
paypal_express GET /express(.:format) piggybak_paypal/paypal#express
paypal_process GET /process(.:format) piggybak_paypal/paypal#process_express
but when I open my website and use /express the server cannot find the route
ActionController::RoutingError (No route matches [GET] "/express"):
I've look around but I can't find a solution to it.
okay I just figure out why the routing is not working and I can't believe I spend hours on this and didn't found out why.
All I did is change the route from
mount PiggybakPaypal::Engine => '/paypal', :as => 'piggybak_paypal'
to
mount PiggybakPaypal::Engine => '/', :as => 'piggybak_paypal'
then /express works.

Url redirection issue in nginx -AmazonEc2 server

I am getting an issue.
We have created a new website for our site using angularJs and ruby on rails.I am using amazon EC2 for hosting purpose.I have used thin and nginx as webserver and application server respectively.
I have made changes in the nginx.conf file and have written redirection rules.However I am having an issue while implementing the same.
While going to TV guide from a website,the url it is showing is :-
http://www.abc.com/WhatsOnTV/Star_world/Boston-legal.aspx?Time=140220141300
It is redirecting me to:-
http://apps.abc.com/WhatsOnTV/Program/Boston_legal.aspx
Whereas it should have landed on:-
abc.com/program/Boston-Legal
This is happening because of the the config file in which I have written the rule(which cannot be removed as we require it ):-
rewrite (?i)^/WhatsOnTV(.*) http://apps.abc.com/WhatsOnTV$1 permanent;
Also another issue I am facing is that the url encoding is different for both.In the old site the space in programs was encoded with _ and in our current site it is encoded with -
My rails routes are the following:-
WoiWeb::Application.routes.draw do
get "appi/index"
get "appi/reco"
get "appi/auto"
get "appi/tsm"
get "appi/user"
get "myaccount/index"
post "myaccount/create"
get "socialfeed/index"
get "myprofile/index"
get "discussion/home"
get "discussion/newdiscussion"
get "sitemap/index"
get "privacy/index"
get "tnc/index"
get "corporate/index"
get "contact/index"
get "about/index"
get "apps/index"
get "videos/index"
get "movies/index"
get "pop_up/show"
get "watchlistsocial/index"
get "favourites/index"
get "reminders/index"
get "channels" => "channel#index"
get "channels/details" => "channel#details"
get "home" => "home#index"
get "languages" => "languages#index"
get "genre" => "genre#index"
get "languages/accounts" => "languages#accounts"
get "programme" => "programme#index"
get "programme/info" => "programme#info"
get "search" => "search#index"
get "movies" => "movies#index"
get "videos" => "videos#index"
get "apps" => "apps#index"
get "tv-guide" => "tv-guide#index"
get "tv-guide/calendar" => "tv-guide#calendar"
get "tv-guide/tvoperator" => "tv-guide#tvoperator"
get "tv-guide/accountstvoperator" => "tv-guide#accountstvoperator"
get "pop-up/show" => "pop-up#show"
get "pop-up/genre" => "pop-up#genre"
get "pop-up/showChannelGenre" => "pop-up#showChannelGenre"
get "pop-up/showRating" => "pop-up#rating"
get "pop-up/reminder" => "pop-up#reminder"
get "user/signin" => "user#signin"
get "user/signup" => "user#signup"
get "user/forgot-password" => "user#forgotPassword"
get "user/popup_login" => "user#popup_login"
get "user/beforeaction" => "user#beforeaction"
get "user/watchlist" => "user#watchlist"
get "user/reminders" => "user#reminders"
get "verify/index" => "verify#index"
get "watchlist" => "watchlist#index"
get "watchlistinfo" => "watchlist#info"
get "movies/popover" => "movies#popover"
get "watchlist/calendar" => "watchlist#calendar"
get "ip" => "ip#index"
get "actor/profile" => "actor#profile"
get "productions" => "productions#index"
get "crawler/crawlhome" => 'crawler#crawlhome'
get "crawler/crawlprogram" => 'crawler#crawlprogram'
get "crawler/crawlchannel" => 'crawler#crawlchannel'
get "crawler/crawlchannels" => 'crawler#crawlchannels'
get "crawler/crawlactor" => 'crawler#crawlactor'
get "crawler/crawltvlistings" => 'crawler#crawltvlistings'
get "crawler/crawlmovies" => 'crawler#crawlmovies'
get "crawler/crawlvideos" => 'crawler#crawlvideos'
get "crawler/crawlmobileapps" => 'crawler#crawlmobileapps'
get "videos/sitemap" => 'videos#sitemap'
So I am stuck with this.Can someone please suggest me some way to tackle this.
Also want to know if it would be better just to make changes in the backend if it's a better option
Your question is confusing. Are you landing to abc.com or to apps.abc.com? In below regex its forwarding to the abc.com
rewrite (?i)^/.*/(.*?)\.aspx\? ht tp://abc.com/program/$1 permanent;
replace ht tp as http from above.

rspec chokes on named path in rails 3

Re-writing a photography portfolio site, and urls have to follow the format:
[site].com/portfolio/[category]/[image]
to match current implementation.
[site].com and [site].com/portfolio should resolve to the root. my routes file is below:
root :to => 'portfolio#index'
match '/portfolio', :to => 'portfolio#index'
match '/portfolio/*category/*photo', :to => 'portfolio#photo'
match '/portfolio/*category', :to => 'portfolio#photo'
I added a link in my header to:
%li= link_to "Portfolio", root_path
and this works fine, but when I add:
%li= link_to "Editorial", portfolio_photo_path
my pages resolve fine in-browser, but rspec chokes out on me; even the simplest http success tests that would previously run fine now return:
1) PortfolioController GET 'index' returns http success
Failure/Error: get 'index'
ActionView::Template::Error:
undefined local variable or method `portfolio_photo_path' for #<#<Class:0x572d210>:0x5733d68>
# ./app/views/layouts/_header.html.haml:7:in `_app_views_layouts__header_html_haml__420220390_28357236'
# ./app/views/layouts/application.html.haml:10:in `_app_views_layouts_application_html_haml__156489427_30065868'
# ./spec/controllers/portfolio_controller_spec.rb:8:in `block (3 levels) in <top (required)>'
(when I rake routes, i get the following)
$ rake routes
root / portfolio#index
portfolio /portfolio(.:format) portfolio#index
/portfolio/*category/*photo(.:format) portfolio#photo
/portfolio/*category(.:format) portfolio#photo
You should add ":as => :portfolio" statement:
match '/portfolio', :to => 'portfolio#index', :as => :portfolio
Answered in my comment above; I'd defined variable-globbed routes, and brain-fartedly didn't realize that i'd have to construct the links directly and dynamically.

Rails Routing help

I have the following in my routes.rb:
match "/profile/permissions" => 'profiles#edit_permissions', :as => 'edit_permissions', :via => :get
match "/profile/permissions" => 'profiles#update_permissions', :as => 'update_permissions', :via => :post
Getting /profile/permissions works find, yet, when I post to /profile/permissions, I get:
Started POST "/profile/permissions" for 127.0.0.1 at 2011-03-29 12:12:09 -0400
ActionController::RoutingError (No route matches "/profile/permissions"):
Any ideas?
Can you put your routes.rb in a gist? Sometimes there's a conflict, and extra eyes are needed to find it. Also, for the sake of fidgeting, you might try out the new shorthand:
get "/profile/permissions" => 'profiles#edit_permissions', :as => 'edit_permissions'
post "/profile/permissions" => 'profiles#update_permissions', :as => 'update_permissions'
Unto themselves, both your routing text and this example successfully trigger their actions on the specified controller.
Start a test app, with only a routing file, run its server, and try to post to those URLs. If you want to use the Rails console, check out this.
> require "uri"
> require "net/http"
> url = app.update_permissions_url
> url = "http://localhost/profile/permissions" (if your domain is bollocks)
> Net::HTTP.post_form(URI.parse(url),{})
Easy to minimalize your environment for testing, now.

Resources