-2
当我点击任何链接或使用重定向时,它总是在URL中追加URL.Like点击我的URL之前看起来像http://plushcash-chat.backtrak.co/ 但是当我点击这里可见的URL变成:http://plushcash-chat.backtrak.co%2C%20plushcash-chat.backtrak.co/URL在点击任何链接时再次被URL追加Rails
我的路线是这样的:
root 'chatrooms#index'
resources :chatrooms do
collection do
get :check_username
end
end
resources :messages
get '/signed_out', to: 'welcome#sign_out_user'
get "leaderboards/top_affiliates"
get '/chat', to: 'welcome#chat'
mount ActionCable.server => '/cable'
控制器代码: 登记控制器
build_resource(configure_sign_up_params)
resource.save
yield resource if block_given?
if resource.persisted?
if resource.active_for_authentication?
set_flash_message! :notice, :signed_up
sign_up(resource_name, resource)
respond_with resource, location: after_sign_up_path_for(resource)
else
set_flash_message! :alert, :"signed_up_but_#{resource.inactive_message}"
expire_data_after_sign_in!
respond_with resource, location: after_inactive_sign_up_path_for(resource)
end
else
clean_up_passwords resource
set_minimum_password_length
respond_with resource
end
cookies.signed[:user_id] = current_user.id
它发生在所有控制器中。我正在使用:
if current_user.present?
@chatroom = Chatroom.new(chatroom_params)
if @chatroom.save
respond_to do |format|
format.html { redirect_to @chatroom }
format.js
end
else
respond_to do |format|
flash[:notice] = {error: ["a chatroom with this topic already exists"]}
format.html { redirect_to new_chatroom_path }
format.js { render template: 'chatrooms/chatroom_error.js.erb'}
end
end
else
redirect_to root_url
end
粘贴你的控制器代码 – puneet18
和看法,特别是形式。路线看起来不错。当我提交表单时,它重定向到了错误的URL,但是当我再次打开主页时,我的会话继续进行。 –
puneet18我在编辑它之后在我的问题中粘贴了上面的控制器代码。 –