users_controller.rb
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
format.html { redirect_to(users_url,
:notice => "The information for #{@user.first_name}
#{@user.last_name} was successfully updated.") }
format.json { head :no_content }
else
format.html { render :action => "edit" }
format.json { render :json => @user.errors, :status =>
:unprocessable_entity }
end
end
end
user.rb
class User < ActiveRecord::Base
belongs_to :team
attr_accessible :team
team.rb
class Team < ActiveRecord::Base
has_many :users
has_many :schedules
attr_accessible :name
end
Perhaps it would be useful if you told us which is line 66.
users_controller.rb
# PUT /users/1
# PUT /users/1.json
def update
@user = User.find(params[:id])
respond_to do |format|
if @user.update_attributes(params[:user])
In case I have made a lucky guess and it is this line then look in
development.log to see what params[:user] will be. Also have a look
at the Rails Guide on debugging to see techniques that can be used to
debug your code.
though in my view/users/index
when i call the following <%= user.team %> i am getting this displayed
#<Team:0x10532a4f0>, i want it to display what team the player has been
allocated to
in my view/teams/show if i call the following
<% for player in @team.users %><%= player.first_name %> <%=
player.last_name %>
i can see what players are loaded for a particular team
? That's not remotely similar to your original example:
when i call the following <%= user.team %> i am getting this displayed
Doesn't it seem apparent that if this <%= user.team %> shows you the
team object, <%= user.team.name %> would show you the e.g. name
attribute of that object?