I’ve come from Django and was wondering how do I specify the default value of model if referenced just by calling it. Ie. <= @user %>
In Django, we can use in the model class;
def __unicode__(self):
return self.fieldname
And it will use whatever field name or combined string we specify. Is this possible in rails?
Cheers,
Ben
You probably want to define
to_sin your model:Then in a view, you can do
<%= @user %>and it’ll output thefieldnameyou specify above.