Hi,
I am new to ruby, so pardon me if i am asking something basic. I am
trying to create a simple test application where a user registers for a
account and can see his profile and edit his profile. the navigation
looks like following:
Register | Profile | Edit_Profile
Profile and Edit_profile and working fine when i use following URL’s:
Profile: http://localhost:3000/user/profile/
Edit_Profile: http://localhost:3000/user/edit_profile/1
but for some routing configuration or some reason it does not display my
registration page after i add “map.resources :user” in routes.rb file.
Register page is at following URL:
Register: http://localhost:3000/user/register
Note: Register page displays and Register functionality works fine
before i add “map.resources :user” in routes.rb, and saves the new user
account in Mysql. but in order to make Profile and Edit_profile work i
have to add “map.resources :user” in routes.rb file.
I only have 1 controller file as “user_controller.rb” which contains
following code:
class UserController < ApplicationController
def register
@title = ‘Register’
if request.post? and params[:user]
@user = User.new(params[:user])
if @user.save
flash[:notice] = ‘New Account created successfuly’
end
end
end
def profile
@title = ‘Profile’
@user = User.find(params[:id])
end
def edit_profile
@title = ‘Edit Profile’
@user = User.find(params[:id])
end
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
flash[:notice] = 'User was successfully updated.'
format.html { redirect_to :controller => 'user', :action =>
‘profile’, :id => User.find(params[:id]) }
format.xml { head :ok }
else
format.html { render :action => “edit_profile” }
format.xml { render :xml => @user.errors, :status =>
:unprocessable_entity }
end
end
end
end
I will be very thankful to the community for any help in this, and
continue to support the community by helping other members as i go.