如何在link_to块中包含nav-item和nav-link

时间:2018-05-06 16:28:34

标签: ruby ruby-on-rails-4

您好我试图在link_to do

中包装此html代码
<li class="nav-item">

<a class="nav-link" href="index.html">

<i class="batch-icon batch-icon-browser-alt"></i>
Dashboard 
</a>
</li>

2 个答案:

答案 0 :(得分:1)

你走了:

<android.support.v7.widget.Toolbar
    android:id="@+id/toolbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:background="@color/colorPrimary"
    app:layout_scrollFlags="scroll|enterAlways"
    app:popupTheme="@style/AppTheme.PopupOverlay">

    <ImageView
        android:id="@+id/mDeleteIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_weight="0.1"
        android:src="@drawable/ic_delete_sweep_black_24dp" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center"
        android:layout_weight="0.8"
        android:text="Alarm"
        android:textColor="@color/tab_background"
        android:textSize="20dp"
        android:textStyle="bold" />

    <ImageView
        android:id="@+id/mAddIcon"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="right"
        android:layout_marginRight="15dp"
        android:layout_weight="0.1"
        android:src="@drawable/ic_add_black_24dp" />
</android.support.v7.widget.Toolbar>

<android.support.v7.widget.RecyclerView
    android:id="@+id/mRecyclerView_id"
    android:layout_width="match_parent"
    android:layout_height="match_parent"></android.support.v7.widget.RecyclerView>


    <FrameLayout 
        android:id="@+id/mAddAlarm"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical"/>
    </LinearLayout>

Here is a link to link_to docs

答案 1 :(得分:1)

您好我终于找到了使用content_tag帮助

的解决方案
    <%= content_tag :li ,class: "nav-item" do%>
        <%=link_to  to_path, class:"nav-link" do%>
        <i class="batch-icon batch-icon-search"></i>
        Dashboard
        <%end%>
    <%end%>

希望它有助于某人