Итак, у меня есть приложение rails app 2.x, которое прекрасно работает через Интернет, но при попытке выполнить POST я продолжаю получать сообщение «Перенаправлено на http://localhost:3000/session/new Цепочка фильтра остановлена как [: require_user] rendered_or_redirected». , В моем приложении для iPhone я могу создать новый сеанс и войти в систему через приложение для iPhone, но не могу POST сказать POSTS_Controller.
У меня есть это в моем коде
Posts_Controller
before_filter :require_user, :only => [:create, :update, :destroy]
Application_Controller
# Filters added to this controller apply to all controllers in the application.
# Likewise, all the methods added will be available for all controllers.
class ApplicationController < ActionController::Base
include AuthenticatedSystem
include Geokit::Geocoders
helper :all # include all helpers, all the time
#session :session_key => '_cwa_session_id'
#filter_parameter_logging :password
# See ActionController::RequestForgeryProtection for details
# Uncomment the :secret if you're not using the cookie session store
protect_from_forgery # :secret => 'eejj7eded74769099999944a729b4f'
#filter_parameter_logging(:password)
before_filter :login_from_cookie
before_filter :find_user_interests
before_filter :find_user_posts
protected
def find_user_interests
@user_interests = cur_user ? cur_user.interesting_posts : []
logger.debug "User interests hash: #{current_user.inspect}"
end
def find_user_posts
@user_posts = cur_user ? cur_user.posts : []
end
def cur_user
User.find(session[:user_id]) if session[:user_id]
end
def require_user
unless cur_user
flash[:error] = "You must be logged in to do that."
redirect_to '/session/new'
return false
end
end
geocode_ip_address
def geokit
@location = session[:geo_location]
end
end
Я работаю над этим 2 месяца и не могу разобраться в проблеме. В моем приложении для iPhone я использую ObjectiveResource. Я отправляю через json, и у меня установлено "Mime :: Type.register_alias" application / json ",: json" на стороне рельсов.