我有一個登錄頁面和一個註冊頁面。我想要點擊登錄或註冊按鈕後,用戶被重定向到另一個視圖,這將是一個微博。重定向按鈕在Ruby on Rails中查看
註冊頁面的代碼如下。 (如在表格部分) -
<h2 class="text-center">Sign Up</h2>
<%= form_for(input_output_SignUp_url) do |f| %>
<%= f.label :first_name,"First name:" %>
<%= f.text_field :first_name %>
<%= f.label :last_name,"Last name:" %>
<%=f.text_field :last_name %>
<%= f.label :email,"Email:" %>
<%= f.email_field :email %>
<%= f.label :phone,"Phone no:"%>
<%= f.text_field :phone %>
<%= f.label :city,"City:" %>
<%= f.text_field :city %>
<%= f.label :addr_1,"Address 1:" %>
<%=f.text_field :addr_1 %>
<%= f.label :addr_2,"Address 2:" %>
<%= f.text_field :addr_2 %>
<%= f.label :state,"State:"%>
<%= f.text_field :state %>
<%= f.label :postal_code,"Postal Code:"%>
<%= f.text_field :postal_code %>
<%= f.label :password,"Password:"%>
<%= f.password_field :password %>
<%= f.label :password_confirmation, "Confirmation:" %>
<%= f.password_field :password_confirmation, class: 'form-control' %>
<%= button_to "View profile", input_output_micropost_path%>
<% end %>
現在這是行不通的。當我按一下按鈕,它顯示了一個錯誤 - 沒有路由匹配[POST]「/ input_output /註冊」
的路由文件如下: -
root 'static_pages#home'
get 'static_pages/home'
get 'static_pages/genre'
get 'static_pages/accessories'
get 'static_pages/contactus'
get 'static_pages/aboutus'
get 'input_output/Login'
get 'input_output/SignUp'
get 'input_output/micropost'
get '/genre', to: 'static_pages#genre'
get '/accessories', to: 'static_pages#accessories'
get '/aboutus', to: 'static_pages#aboutus'
get 'contactus', to: 'static_pages#contactus'
get 'Home', to: 'static_pages#home'
get '/Login', to: 'input_output#Login'
get '/micropost', to: 'input_output#micropost'
get '/SignUp', to: 'input_output#SignUp'
end
我怎樣才能讓這個錯誤消失了?
編輯: - 作爲問,這是耙路線 /home/gauri/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/activesupport-5.0的結果。 1/lib/active_support/xml_mini.rb:51:警告:常量:: Fixnum已棄用
/home/gauri/.rbenv/versions/2.4.0/lib/ruby/gems/2.4.0/gems/ activesupport-5.0.1/lib/active_support/xml_mini.rb:52:warning:constant :: Bignum is deprecated
/home/gauri/.rbenv/versions/2.4.0/lib/ruby/gems/2.4。 0/gems/activesupport-5.0.1/lib/active_support/core_ext/numeric/conversions.rb:138:warning:constant :: Fixnum已棄用
耙子中止了!
ArgumentError:缺失:路由定義中的控制器鍵,請檢查您的路由。
/家庭/薇思瓦納/教學/ CS/Ruby on Rails的/獎學金/獎學金/配置/ routes.rb中:25:在'塊'
/家庭/薇思瓦納/教學/ CS/Ruby on Rails的/ScholarShip/ScholarShip/config/routes.rb:1:in` '
/家庭/薇思瓦納/教學/ CS/Ruby on Rails的/獎學金/獎學金/到config/environment.rb:5:`'
任務:TOP => routes =>環境
做你想要什麼關聯看法?請運行'rake routes'併發布輸出。 –
您的所有路線都是「獲取」請求。你需要添加一條路徑,將數據從表單「張貼」到一個控制器,以及你正在處理的行爲。發佈'input_output/SignUp' – bkunzi01
@AlejandroMontilla我想將它鏈接到名爲'micropost'的視圖,它是控制器的一部分,名爲InputOutput,它也包含註冊頁面和登錄頁面。 – sindhugauri