Skip to main content

Questions tagged [erb]

eRuby (Embedded Ruby) is a templating system that embeds Ruby into a text document. It is often used to embed Ruby code in an HTML document, similar to ASP, JSP and PHP.

Filter by
Sorted by
Tagged with
7 votes
4 answers
4k views

Avoid printing attributes of the nil object in Rails

Currently, when I'm wanting to print a value for my class I do the following... <%= @person.team.name if @person.team.present? %> This seems really ...
moopasta's user avatar
  • 173
1 vote
1 answer
59 views

Sign up/in partials

I currently have two partials that I use for signing up and signing in. The code is essentially the same in both except for different images to represent sign up/in via Facebook/Twitter. _sign_in_via....
SoSimple's user avatar
  • 237
3 votes
1 answer
188 views

Hide content unless an array contains at least one non-empty string

I have an array of hints. Sometimes, this array could contain an empty string. Occasionally, the array might contain only empty strings, in which case I want the whole block to be skipped. This is ...
Phasy's user avatar
  • 65
2 votes
1 answer
812 views

Controller and view to call multiple instance variables

I have a Rails 3.2.14 app where I have a home controller (dashboard). In this controller and view I'm calling multiple instance variables to get different counts based off of scopes I've created in ...
nulltek's user avatar
  • 139
1 vote
1 answer
1k views

Moving instance variable from partial to helper

I want to display a town name in my navigation, depending on the town I am requesting from the model. The following code works, but I am mixing logic in my view which I know is wrong and I haven't ...
chris_s's user avatar
  • 111
6 votes
1 answer
10k views

Best way to include image_tag inside link_to

What is the most elegant and readable way to in include (potentially long) image_tag calls inside of link_to? Example ...
cseelus's user avatar
  • 165
6 votes
2 answers
777 views

Showing items as in a Carousel

Is there a better way to implement my carousel in less lines? ...
thmsmxwll's user avatar
  • 107
2 votes
1 answer
786 views

Custom FormBuilder

I'm starting Rails and Ruby for a short time. But I try to make it the cleanest way I can. So, in an attempt to clean my view, I try to custom my FormBuilder: <...
Juaniyyoo's user avatar