【发布时间】:2011-09-02 04:18:59
【问题描述】:
这是我的控制器。因为控制器包含通过 API 推送 HTML 字符串的逻辑,并且 HTML 包含链接,所以挑战之一是表示 link_to 帮助器的输出:
client = LinkedIn::Client.new(ENV['LINKEDIN_KEY'], ENV['LINKEDIN_SECRET'])
57 client.authorize_from_access(current_user.atoken, current_user.asecret)
58 public_profile_url = client.profile(:fields => "public-profile-url").public_profile_url
59 string = "<a href='#{public_profile_url}'>#{current_user.full_name}</a> has shared: "
60 string = string + "<a href = 'http://www.domain.com/question/#{@question.id}'>#{@question.title}</a>"
61 #<a href='http://www.domain.com/review/#{@review.id}'>#{@review.title}</a> "
62 debugger
63 client.update_network(string)
这组代码是相同的,但用于其他资源,所以我想将这一切都作为控制器内部使用的单个模块进行干燥。
我尝试将它放在帮助器中,但这根本不起作用:ssay 帮助器方法是未知的。
【问题讨论】:
标签: ruby-on-rails controller dry helper