Ruby on Rails creation of models -
i created 2 controller , view named
rails new generate controller home page rails new generate controller login index created model named login , code is
class login include mongoid::document field :username, type: string field :password, type: string end home controllers page action contains code
<%= link_to "enter details",controller: "login" %> login_controller contains
class logincontroller < applicationcontroller def index @log=login.new end end and login controllers index action contains code form
<%= form_for(@log) |l| %> <%= l.label :username %><br> <%= l.text_field %> <br> <%= l.label :password %><br> <%= l.text_field %><br> <%= l.submit :login %> <% end %> after executing gives me error , screen here.
and routes.rb file contains following codes.
new_project::application.routes.draw "login/index" "home/page" resources :products root 'home#page' end where did went wrong .?
by default form_for using post method send data. in routes have route login action. if want use restful routes, add line
resource :login if want add index/create routes
resource :login, :only => [:index, :create] more info rails routing.
Comments
Post a Comment