Problem displaying author's name on the post assigned

hi all,

newb still learning here, i'm having problems displaying the author's
login name and instead it's displaying the author's id# in mysql. i'm
currently using the acts_as_authenticated plug in which seems to be
working fine and i've assigned the posts to the authors by: @post.user =
current_user

the user login is stored as login but i have no idea how to call the
user's login field in the controller i was thinking using something like
@user = @user.login but it didn't work so i gues i'm doing something
wrong.

here is the code:

in the controller:
def show
    store_location
    @post = Post.find(params[:id])

  end

in the view:
<span>
Posted by : <%= link_to @post.user_id -%>
<%= distance_of_time_in_words_to_now(@post.created_at) %> ago
</span>

<span>
<%= @post.location %></span>

thank you alll

Richard Yoo wrote:

hi all,

newb still learning here, i'm having problems displaying the author's
login name and instead it's displaying the author's id# in mysql. i'm
currently using the acts_as_authenticated plug in which seems to be
working fine and i've assigned the posts to the authors by: @post.user =
current_user

the user login is stored as login but i have no idea how to call the
user's login field in the controller i was thinking using something like
@user = @user.login but it didn't work so i gues i'm doing something
wrong.

here is the code:

in the controller:
def show
    store_location
    @post = Post.find(params[:id])

  end

in the view:
<span>
Posted by : <%= link_to @post.user_id -%>
<%= distance_of_time_in_words_to_now(@post.created_at) %> ago
</span>

<span>
<%= @post.location %></span>

thank you alll

Try this:

Posted by: <%= link_to @post.user.login, :controller => 'users', :action
=> 'show', :id => @post.user %>

Assuming you have a UsersController with a show action, this should
work. You could clean it up a bit with name routes.