Conditional Logic on link_to with a block.

I've got some ugly code I don't know how to improve on. I've got a
link_to tag that takes a fair amount of html as a block. I need the
href value for the link to be different depending on some logic, there
are four possible values for the href.

What I ended us with was this, and it's pretty unreadable. Any
suggestions on how to do this better?

                      <%= link_to (@brand.nil? ? (@store.nil? ?
(from_catalog_path(params[:id].blank? ? :
params[:id],, product.name_url)) :
(from_store_path(, :
(from_brand_path(, do -%>
                            ...... HTML IN HERE .....
                      <% end %>

Maybe just put the logic in the controller?

if @brand.nil?

if @store.nil?

@brand_link_path = from_catalog_path(params[:id].blank? ? : params[:id],, product.name_url)


@brand_link_path = from_store_path(,



@brand_link_path = from_brand_path(,


Then it simplifies your view:

<%= link_to(@brand_linnk_path) do -%> HTML HERE <% end %>