Abhilash
Abhilash

Reputation: 2953

adding a div block to all pages except a particular page in rails

I want to add this div block to my application.html.erb so that it will show in all pages. So I done like below.

<div class="contaner-fluid custom-padding full-page-height">

</div>

But I dont want to show it on my home action.So is there any way to do that?

Upvotes: 1

Views: 112

Answers (2)

mmhan
mmhan

Reputation: 731

Rails Guides says:

The params hash will always contain the :controller and :action keys, but you should use the methods controller_name and action_name instead to access these values

Definitely, you may make use of controller_name and action_name to check if it's the one that you wish to exclude. Assuming your controller name is foos then you can do the following:

<% if !(controller_name == "foos" && action_name == "home") %>
<div class="contaner-fluid custom-padding full-page-height">

</div>
<% end %>

Upvotes: 2

user163131
user163131

Reputation: 26

Modify the above code to this

<% unless params[:action] == 'home' %>
    <div class="contaner-fluid custom-padding full-page-height">

    </div>
<% end %>

Upvotes: 1

Related Questions