-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我在編輯它之後在我的問題中粘貼了上面的控制器代碼。 –