@user = User.new(name: '')
[...]
= text_field_tag :pseudo, nil, value: params[:pseudo] || @user.name
# doesn't work :'(
= text_field_tag :pseudo, nil, value: params[:pseudo].present? ? params[:pseudo] : @user.name.present?
# works, but ugly, x2 character count ! :'(
class String
def **(other) # 'other' is rubocop's rule for the ** ! ;)
present? ? self : other
end
# be carefull in method name : def |(other) was better, but doesn't work for NilClass : nil | 'foo' > true
end
= text_field_tag :pseudo, nil, value: params[:pseudo] ** @user.name
# works :-D