No route matches [GET] "/users/assets/bootstrap.min.js" only in Firefox? - ruby-on-rails

Firefox gives me this error when i try to sign in or sign up into my app, i am only working locally and i am using devise gem for this. After loading the form it cracks into this routing. The file bootstrap.min.js is in the stylesheets folder and into assets folder. In the layouts i have declared:
<script src="assets/bootstrap.min.js"></script>
Chrome and Safari does not have any problem. Another strange behavoir, i guess related to the same issue, is that when i try to inspect element it falls into this error:
No route matches [GET] "/assets/bootstrap.min.css.map"
The Routes file is done like this:
Rails.application.routes.draw do
resources :properties
devise_for :users
root "properties#index"
get "about" => "pages#about"
get "user_properties" => "pages#user_properties"
get "contact" => "pages#contact"
Anyone have a clue?

try this:
<script src="/assets/bootstrap.min.js"></script>

Related

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.

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.

Routing to static html page in /public

How can I route /foo to display /public/foo.html in Rails?
You can do this:
Add this, into your routes.rb file.
match '/foo', :to => redirect('/foo.html')
Update
In Rails 4, it should use "get", not "match":
get '/foo', :to => redirect('/foo.html')
thanks Grant Birchmeier
This can be done without triggering a redirect. Follow the steps further down to be able to route static files in config/routes.rb as shown in this example:
# This route will serve public/index.html at the /login URL
# path, and have a URL helper named `login_path`:
get "/login", to: static("index.html")
# This route will serve public/register.html at the /register
# URL path, and have URL helper named `new_user_registration_path`:
get "/register", to: static("register.html"), as: :new_user_registration
Install the rails-static-router gem: https://github.com/mufid/rails-static-router#installation
Restart app (first bin/spring stop to be sure app is completely reloaded).
Start using the static(path) method in your config/routes.rb.
E.g in Rails 4 add the following route:
get '/example', :to => redirect('example.html')
Also you need to enable static files from the 'public' directory in your configuration:
config.serve_static_files = true
OR
config.serve_static_assets = true
Also you might need to provide your public directory as root in NGINX configuration.

Basic Rails3 routes question?

My routes.rb has the following 2 lines:
match "/", :to => "main#index"
match "main/index", :to => "main#index"
When I type localhost:3000/main/index in a browser I see the proper page (views/main/index.html.erb).
However, if I type just localhost:3000 I see public/index.html (I expect to see views/main/index.html.erb as well).
What am I missing ?
Remove public/index.html:
rm public/index.html
This is happening because static files (those in public/) are served in priority to the routes.

Rails 3 & Sinatra integration issue

I am trying to set up a sinatra app inside my Rails 3 (v3.0.1) application, but having no success. Sinatra gem (v1.1.0) is setup using bundle install.
Here's what i have.
customer_app.rb class in lib directory -
class CustomerApp < Sinatra::Base
get "/test" do
"Hello World"
end
end
my routes.rb file contains -
CustomerService::Application.routes.draw do
root :to => CustomerApp
end
The URL i am trying is - http://localhost:3000/test
I get this error (on the browser) - Routing Error. No route matches "/test"
and this error in the log - ActionController::RoutingError (No route matches "/test"):
Is there anything I am missing??
Also I just noticed, even a simple rack route is not working -
root :to => proc { |env| [200, {}, ["Welcome!"]]}
The root keyword by default maps only the path /.
So you are trying to say, forward any request for / to CustomerApp which can handle requests for /test.
You should change the match filter.
CustomerService::Application.routes.draw do
match "/test" :to => CustomerApp
end

Resources