1

In the view have a string, that shows from a database string with the website address. How to make so that would absence of this website address in the database, the string will not be displaying the view?

website:
<%= link_to @restaurant.site, url_with_protocol(@restaurant.site) >

in the absence website address remains the first string, and I wish that it only appears when there address

PS

That this could be done, as in writing this code:

<% if session[:user_id] %> <% end >

which displays information only if the user is registered.

1 Answer 1

1

Just do it the same way.

<% if @restaurant.site %>
  <%= link_to @restaurant.site, url_with_protocol(@restaurant.site) %>
<% end %>
Sign up to request clarification or add additional context in comments.

2 Comments

link_to_if if its there in RoR 3. Seen it in Rails 2.
I think it still leaves the text, doesn't it ?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.