Rails Engine not routing in webpage - ruby-on-rails

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.

Related

RoR, Sizzle Uncaught Error: Syntax error, unrecognized expression: /sv/priser

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.

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.

Refinery Image Uploading giving no route match (How do you change default image route in refinery?)

When uploading an image to the Refinery CMS I get a broken link.
No route matches [GET] "/system/images/W1siZiIsIjIwMTMvMDUvMDgvMjFfMjBfMjFfMzlfc3RlYWtfZmluYWwuanBnIl1d/steak-final.jpg"
Any idea why could this be happening or is there a fix?
UPDATE: The problem is that I am mounting Refinery on "/cms" instead of the root path.
But I still don't know how to change the picture route. If I add:
/cms
in front of the image path it works.
ROUTES
root :to => 'static#home'
get "vault", :to => "restricted_content#vault"
Refinery::Core::Engine.routes.prepend do
get '/courses/:id/classroom', :to => 'courses/courses#classroom'
end
mount Refinery::Core::Engine, :at => '/cms'
devise_for :users
RefineryCMS needs to be mounted at root to work properly. Why is it important to mount it at cms?
Read through this issue # github. I've provided a monkeypatch for this issue.

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