Routing Error

my register.html.erb file is :

<% form_for :user do |form| %>


Enter Your Detail Screen Name

Email

Password

<%end%>

and my user controller is

class UserController < ApplicationController

def index
end

def register
@title=“Register”
if request.post? and params[:user]
@user = User.new(params[:user])
if @user.save
render :text =>“user created!”
end
end

end

end

my application.html.erb is

My web Site <%= stylesheet_link_tag "site" %> <%= javascript_include_tag :defaults %> <%= csrf_meta_tag %>

My Website

<%=link_to "Register",:action =>"register", :controller=>"user"%>| <%=link_to "Index",:action=>"index",:controller=>"site"%>| <%=link_to "About Us",:action=>"about",:controller=>"site"%>| <%=link_to "Help",:action=>"help",:controller=>"site"%>

<%= @contenet_for_layout%>

<% if ENV["RAILS_ENV"] == "development" %> <%= debug(params)%> <% end %>

<%= yield %>

i dont no why i am getting routing error when i am click register
button

First of all , why arent you been restful?? your register action is the
same
as a new action, rails creates the right routes for it with
resource :user if you name that action new instead of register, you can
use
the :as method to make it say what you want in the url string. second
why
are you testing the http method? that is a requirement the router
handles.
and last , what is this for : @title=“Register” ?

First of all , why arent you been restful?? your register action is the
same as a new action, rails creates the right routes for it with
resource :user if you name that action new instead of register, you can
use the :as method to make it say what you want in the url string. second
why are you testing the http method? that is a requirement the router
handles. and last , what is this for : @title=“Register” ?

sorry i said you should name the action new but you should name it
create

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs