ruby - No Method Error // Helper // Rails 3 -


i'm trying admin avatar gravatar using email address. copied code ryan bate's railscast http://railscasts.com/episodes/244-gravatar

the application helper:

module applicationhelper   def avatar_url(current_admin)     if current_admin.avatar_url.present?       current_admin.avatar_url     else       default_url = "#{root_url}images/guest.png"       gravatar_id = digest::md5.hexdigest(current_admin.email.downcase)       "http://gravatar.com/avatar/#{gravatar_id}.png?s=48&d=#{cgi.escape(default_url)}"     end   end end 

my application controller has helper :all

my view has <%= image_tag, avatar_url(current_admin), :class => "img-circle" %> error nomethoderror , more specifically, undefined method 'avatar_url' #<admin:0x007fc4ae804ee8>

the current_admin set devise.

i looked through railscast , poor actually. @ 1 point ryan says add avatar_url user without giving hint data field should come from.

so unfortunately need add field creating rails migration if using activerecord.

rails g migration addavatarurltouser avatar_url 

but required if want allow users having own non-gravatar images. if want stick gravatar ones can skip section "using images other sites omniauth"


Comments

Popular posts from this blog

javascript - DIV "hiding" when changing dropdown value -

Does Firefox offer AppleScript support to get URL of windows? -

android - How to install packaged app on Firefox for mobile? -