0
Как отобразить все социальные учетные записи, которые подключили пользователя? Можно ли сделать дисплей проще?как отображать все социальные учетные записи, которые подключили пользователя?
В просмотров:
<%= twitter_profile(@user) %>
<%= facebook_profile(@user) %>
<%= linkedin_profile(@user) %>
<%= google_profile(@user) %>
<%= instagram_profile(@user) %>
Helper:
def twitter_profile(user)
user.twitter_profile ? image_tag(user.twitter_profile.profile_picture_url) : ""
end
def facebook_profile(user)
user.facebook_profile ? image_tag(user.facebook_profile.profile_picture_url) : ""
end
def linkedin_profile(user)
user.linkedin_profile ? image_tag(user.linkedin_profile.profile_picture_url) : ""
end
def google_profile(user)
user.google_profile ? image_tag(user.google_profile.profile_picture_url) : ""
end
def instagram_profile(user)
user.instagram_profile ? image_tag(user.instagram_profile.profile_picture_url) : ""
end
Вы можете упростить отображение с частичным. И СУШЬ ваши помощники с метапрограммированием тоже. –
@ismail, вы можете попробовать посмотреть, работает ли метапрограммирование. –