OK, so I'm just migrating my first project from Rails 3 to Rails 4, the project is under development and so has certain links that are only there for the sake of content.
In Rails 3 I could do this:
link_to "To be added", {:controller => "#", :action => "#"}
This would give me a dummy link that I could style etc. This does not work in Rails 4 due to a routing error:
No route matches {:action=>"#", :controller=>"#"}
It could just be that I'm slightly sleep deprived at the moment but I can't seem to figure out a decent way of solving this and achieving the same functionality.
为什么不是这样的: link_to "To be added", "#"
?
我只是使用<%= link_to“添加”%>
So, it was definitely sleep deprivation, less than a minute after writing this I figured it out.
by using:
link_to "To be added", {:controller => "dummy", :action => "dummy"}
and adding a corresponding dummy route in the routes.rb file:
get "dummy/dummy" => "dummy#dummy"
it all works again, yay
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.