Sunday, 15 January 2012

ruby on rails - How can I access to assets/image -



ruby on rails - How can I access to assets/image -

i have image called 18.png in assets/images/languages/

then have attribute called language assuming, current_user.language = 18

how can access , show image in view?

simply append users language attribute relative language asset path within view.

<%= image_tag "languages/#{current_user.language}.png" %>

if you're going using throughout application should move helper method, e.g. :

def user_locale_tag image_tag "languages/#{current_user.language}.png" end

in authentication scheme you'll want ensure current_user exists before hand.

ruby-on-rails ruby-on-rails-3

No comments:

Post a Comment