2013-02-21 49 views
-2

我只需要顯示文本,如果用戶在posts_edit_path,我該怎麼做呢?如果當前頁面posts_edit_path然後顯示文本

謝謝!

我的帖子形成,我想將此文本(睞izdzēstubildes,ieklikšķinietTAS聯合國publicējietrakstu。)只有誰在posts_edit_path

<%= nested_form_for(@post) do |f| %> 
    <% if @post.errors.any? %> 
    <div id="error_explanation"> 
     <h2><%= pluralize(@post.errors.count, "error") %> prohibited this post from being saved:</h2> 

     <ul> 
     <% @post.errors.full_messages.each do |msg| %> 
     <li><%= msg %></li> 
     <% end %> 
     </ul> 
    </div> 
    <% end %> 

    <div id="field"> 
    <%= f.label :Nosaukums %>:<br /><br /> 
    <%= f.text_field :title %><br /><br /> 
    </div> 
    <div id="field"> 
    <%= f.label :Raksts %>:<br /><br /> 
    <%= f.text_area :content %><br /><br /> 
    </div> 
    <div id="field_browse"> 
    <b><%= f.label :Bildes %>:</b><br /> 
     Lai izdzēstu bildes, ieklikšķiniet tās un publicējiet rakstu.<br /><br /> 
    <%= f.fields_for :assets do |asset| %> 
     <% if asset.object.new_record? %> 
     <div style="clear: both;"></div> 
      <%= asset.file_field :image %>   
      <%= f.link_to_remove "Noņemt" %> 
     <% end %> 
     <% unless asset.object.new_record? %> 
     <p> 
      <div id="pictures_in_form"><%= link_to image_tag(asset.object.image.url(:thumb)), asset.object.image.url(:big), :class => "fancybox", :rel => "gallery" if asset.object.image? %></div>       
      <div id="delete_box"><%= asset.check_box :_destroy if asset.object.image?%></div> 
     </p> 
     <% end %> 
    <% end %> 
    <%= f.link_to_add "Pievienot bildes", :assets %> 
    </div> 
    <div style="margin-top: 15px;"> 
    <%= f.submit "Publicēt rakstu", :id => "button-link" %> 
    </div> 
<% end %> 
+0

請張貼代碼,並闡述你想要什麼去做。你試過什麼了? – jxpx777 2013-02-21 15:31:21

回答

1

你可以這樣做:

<div id="field_browse"> 
<b><%= f.label :Bildes %>:</b><br /> 
<%= "Lai izdzēstu bildes, ieklikšķiniet tās un publicējiet rakstu." if action_name.eql? "edit" %> 
    <br /><br /> 
<%= f.fields_for :assets do |asset| %> 
    <% if asset.object.new_record? %> 
    <div style="clear: both;"></div> 
     <%= asset.file_field :image %>   
     <%= f.link_to_remove "Noņemt" %> 
    <% end %> 
    <% unless asset.object.new_record? %> 
    <p> 
     <div id="pictures_in_form"><%= link_to image_tag(asset.object.image.url(:thumb)), asset.object.image.url(:big), :class => "fancybox", :rel => "gallery" if asset.object.image? %></div>       
     <div id="delete_box"><%= asset.check_box :_destroy if asset.object.image?%></div> 
    </p> 
    <% end %> 
<% end %> 
<%= f.link_to_add "Pievienot bildes", :assets %> 

+0

謝謝!你幫了我很多! – RydelHouse 2013-02-21 15:52:33

2

CURRENT_PAGE用戶?應該幫助你做你想做的事情。例如:

if current_page?(:controller => "post", :action => "edit") 

看看這個鏈接獲取更多信息:ruby on rails api: current_page?

相關問題