奧利爲基礎,但我有一個時間地獄得到一個非常基本的流量的工作:NoMethodError在<myController的>#<myMethod>未定義的方法`<myModuleMethod>」爲<myModule>
1)定義模塊與保存url到VAR(或歸還)
2)調用該方法在控制器初始化方法
3)有一個觀點顯示了一種方法,URL
NoMethodError在AuthController #oauth undefined metho d`oauthurl」的GetAccessToken:模塊
模塊:\ lib中\ get_access_token.rb
module GetAccessToken
CONSUMER_TOKEN = { :token=>"mytokenstringwhichisreallylong", :secret=> "mysecretstringwhichisreallylong" }
def self.oauthurl
@oauthurl="https://us.etrade.com/e/t/etws/authorize?key=#{(CONSUMER_TOKEN[:token])}&token="
end
end
控制器:應用\控制器\ auth_controllers.rb
require 'get_access_token'
class AuthController < ApplicationController
include GetAccessToken
before_filter :oauthurl1
def oauthurl1
GetAccessToken.oauthurl
end
end
檢視:應用\視圖\ AUTH \ oauth.html.erb
<% provide(:title, 'oAuth') %>
<h1>oAuth</h1>
<%= link_to "oAuth", @oauthurl %>
我更高層次的目標是讓ETRADE OAuth的流動工作,但我婉以確保我理解每一行代碼與接受其他人的代碼,並且我無法獲得這個非常基本的構建模塊的工作。
謝謝 - 我想這燙髮utation(將配置行添加到application.rb;初始化oauthurl1),但不幸的是,這還沒有爲我工作 - 同樣的錯誤。 –