开发者

Display Partial if user on specific page

开发者 https://www.devze.com 2023-03-28 02:03 出处:网络
If I have a page with the following URL: http://www.mywebsite.com/users/profile/edit How would I display a partial ONLY if the user is on that particular page?

If I have a page with the following URL: http://www.mywebsite.com/users/profile/edit

How would I display a partial ONLY if the user is on that particular page?

Someone suggested this code, but the syntax confuses me and I was hoping for something more specific. <%= render :partial => 开发者_StackOverflow中文版"foo/bar" if @conditions %>


Usually you put the call to display the partial in the view for that action. If you have a view used by more than one, the standard procedure is as you describe where @conditions represents some arbitrary conditions. It could be like this:

<%= render(:partial => 'example') if (params[:action] == 'edit') %>
0

精彩评论

暂无评论...
验证码 换一张
取 消