Note that there are some explanatory texts on larger screens.

plurals
  1. PONo action responding to my link
    text
    copied!<p>I have a simple web app with users and posts. I have an index controller and view that shows a list of the posts in the database. With the list, it shows a "Show" link which links to the specific post.</p> <p>I am trying to replicate that for users but something is going wrong. I have an index view that shows all the users in the database and I have a "Profile" link which should link to a specific user. (Show action is already being used for users own account) See code below, the User Profile action is the same as the Post Show action but it doesn't work.</p> <pre><code># users_controller.rb def index @users = User.all respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @users } end end def profile @user = User.find(params[:id]) respond_to do |format| format.html # show.html.erb format.xml { render :xml =&gt; @user } end end # posts_controller.rb def index @posts = Post.all respond_to do |format| format.html # index.html.erb format.xml { render :xml =&gt; @posts } end end def show @post = Post.find(params[:id]) @user = User.find_by_id(@post.user_id) respond_to do |format| format.html # show.html.erb format.xml { render :xml =&gt; @post } end end # users/index.html.erb &lt;h1&gt;Listing All Users&lt;/h1&gt; &lt;table&gt; &lt;tr&gt; &lt;th&gt;Name&lt;/th&gt; &lt;th&gt;Email&lt;/th&gt; &lt;/tr&gt; &lt;% @users.each do |user| %&gt; &lt;tr&gt; &lt;td&gt;&lt;%= link_to user.login, user %&gt;&lt;/td&gt; &lt;td&gt;&lt;%=h user.email %&gt;&lt;/td&gt; &lt;/tr&gt; &lt;% end %&gt; &lt;/table&gt; &lt;br /&gt; </code></pre> <p>I am thinking it may be a problem in my routes. But I can't see anything.</p> <pre><code> map.connect ':controller/:action/:id' map.connect ':controller/:action/:id.:format' map.root :controller =&gt; "Home" map.resource :account, :controller =&gt; "users" map.resources :password_resets map.resources :users map.resource :user_session map.root :controller =&gt; "user_sessions", :action =&gt; "new" map.resources :users, :has_many =&gt; :posts </code></pre> <p>When I try go to users/1 I get "No action responded to 1. Actions: create, edit, index, new, profile, show, and update"</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload