Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display Partial if user on specific 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 => "foo/bar" if @conditions %>

like image 405
webbydevy Avatar asked Dec 12 '22 10:12

webbydevy


1 Answers

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') %>
like image 124
tadman Avatar answered Dec 26 '22 09:12

tadman