2016-05-11 37 views
-1

我有兩個控制器:的link_to不起作用RubyOnRails

MainController with pages: index.html.erb 
LoginController with pages: login.html.erb, signup.html.erb, pasfor.html.erb 

這是我的路線

https://gyazo.com/4acf99c74bbb7999d580e32fd1496386 

我創建

<%= link_to '<li id="login-button"><i class="fa fa-plus"> Create event</i></li>'.html_safe, login_login_path %> 

這從index.html的重定向。 erb to login.html.erb

I想要在login.html.erb中設置一個重定向到signup.html.erb的按鈕。所以我做了同樣的事情。按鈕在那裏,但當我點擊沒有發生。

<%= link_to '<button type="submit" class="btn btn-default">Register</button>'.html_safe, login_signup_path %> 

回答

1

看起來您正在使用Bootstrap。在引導,你可以創建一個鏈接,看起來像btn btn-default類按鈕是這樣的:

<%= link_to 'Register', login_signup_path, class: 'btn btn-default' %> 

獎勵:你的第一個link_to例子是有點過了。你不應該像a那樣將塊級元素li放入內聯元素中。

考慮這樣的事情,而不是:

<li id="login-button"> 
    <%# Tip: you can pass a block to `link_to` to nest more complex HTML inside %> 
    <%= link_to login_login_path do %> 
    <%# 
     # Tip: You should close a Font Awesome icon immediately. 
     # (Never put content inside of the `i` tag.) 
     # %> 
    <i class="fa fa-plus"></i> Create event 
    <% end %> 
</li> 
+0

這是一些金色的指教,謝謝! –