Kiedy proboje wywolac akcje index dostaje komunikat
Oczywiscie jestem zalogowany w sessji jest wszystko co potrzeba. Jak zmienie @user = User.find(current_user) na np @user = User.find(2) wszystko dziala. Inne metody oprocz tej self. widza current_user
[code=ruby]class TwittersController < ApplicationController
require “oauth”
layout “application”
def self.consumer
@user = User.find(current_user)
@consumer = OAuth::Consumer.new(@user.customer_key,@user.customer_secret, :site => “http://api.twitter.com”)
end
def index
@request_token = TwittersController.consumer.get_request_token(:oauth_callback => “http://localhost:3000/twitters/new”)
session[:request_token] = @request_token.token
session[:request_token_secret] = @request_token.secret
redirect_to @request_token.authorize_url
end
end[/code]
[code=ruby]class ApplicationController < ActionController::Base
helper :all # include all helpers, all the time
protect_from_forgery # See ActionController::RequestForgeryProtection for details
Scrub sensitive parameters from your log
filter_parameter_logging :password
helper_method :current_user_session, :current_user, :authentication
private
def current_user_session
return @current_user_session if defined?(@current_user_session)
@current_user_session = UserSession.find
end
def current_user
return @current_user if defined?(@current_user)
@current_user = current_user_session && current_user_session.user
end
end[/code]
[color=#FF0000]Edit[/color]
Przeslalem current_user do self.consumer i dziala. Czy to poprawne rozwiazanie ?
def self.consumer(user)
@user = User.find(user)
end
@request_token = TwittersController.consumer(current_user).get_request_token(:oauth_callback => “http://localhost:3000/twitters/new”)