link_to Base URL Randomly Changed

2019-08-30 07:01发布

问题:

I'm using link_to to create a custom link. For some reason, my url always is wrong and randomly adds blog to the URL. I can't figure out why. It only does this while within the partial that I am rendering (3 times on the page).

I can share any code necessary, but where the hell would it randomly grab the blog URL?

The browser renders:

<a href="/blog?controller=quote">Select Rate</a>

My view (using slim) is:

- for rate in loantek_rates
  - loantek_closing_costs = LoantekClosingCosts.new(rate)
  = link_to 'Select Rate', {controller: 'quote'}

Routes

#routes.rb
match "/blog" => redirect("http://blog.mywebsite.com"), path: '/blog'
resources :quotes, path: 'quote'

回答1:

Set paths in link_to tag which you can get from rake_routes

Ex.

link_to "Profile", profile_path(@profile)