Reputation: 4049
I have a block of disclaimer text used across multiple pages/ partials. I figure I could:
Example of #3:
def disclaimer
@text = "text"
end
def homepage
disclaimer
end
def page_one
disclaimer
end
# then the view file for homepage or page_one would just call @text
Which of these ways is more "Rails"?
Upvotes: 0
Views: 523
Reputation: 26
As stated in your question, there are a few ways to do this. Your best best is to either use a partial, or make a helper and define a method for your disclaimer in the helper.
Helpers should be a bit faster, because they aren't rendering the partial. This is the best bet if your disclaimer is static text. If you are using any HTML in your disclaimer, it would probably be better to use a partial.
Example helper:
module DisclaimerHelper
def disclaimer
"This is the static text of my disclaimer."
end
end
Upvotes: 1
Reputation: 6404
I would definitely go with option 1. Environment variables are usually reserved for credentials to services that your app uses and option 3 seems like it would be a little more complex than option 1.
Upvotes: 0