ruby - Call gravatar_for in Rails Model -
I am trying to call gravatar_for one of my models. (Yes, I realize that it is not strictly MVC, but I have a valid reason to do this which I am not going to). I am trying to include helpers for Gravatar, but I have not been able to know what they are.
By adding this to my class so far does not work:
Announcement of the class posted activity & lt; GravatarHelper :: PublicMethods in Newsfeed Activity
Assume that you want to generate an image tag There are some problems to overcome using. Note that the gravatar_for method takes a user object as its first argument. Commenting in your in GravatarHelper :: PublicMethods class all the examples gravatar_for (user, option = {} ) .) Then you will say: alice = user.new () alice.respond_to? (: Gravatar_for) = & gt; Error for true alice.gravatar_ logic: Wrong number of arguments (1 to 0) # (You need to argue - method became zero, but one was expected) alice.gravatar_for (alice) = & gt; "& Lt; img class = \" gravatar \ "alt = \" \ "width = \" 50 \ "height = \" 50 \ "src = \" http://www.gravatar.com/avatar/70375a32ad79987b9bc00cb20f7d1c95? Rating = PG & amp; Amp; Size = 50 \ "/> # (not what we absolutely want) You see, you must supply the user object gravatar_for The first argument of the method, what do you have to do? 1. Use another gem
The one that provides a module on it Self.email instead of requiring it as a method parameter. 2. Apply the self rule
. And follow it for example. Maybe << em> Eno Some train assistants need to be included in the posterified activity & gt; gravatar_url 'github @ deanandadie.net` node method arrowroof:' H 'for the undefined method main: Object ....> Active 'support_support / core_ext / string / output_safety' => true>> ERB :: ULL => object> gt; gravatar_url 'github @ Deanandadie.net` = & gt; "http: // www. Gravatar.com/avatar/fbaf55d6c2618cafe0a759cfe85967e0?rating=PG&size=50 "
Comments
Post a Comment