Home>

rails I am a beginner.

Currently, we are working on a simple golf score input application with rails and are adding user functions.
According to theory, I made a model, set a controller and a view, and accessed 〇〇/users with a browser, but the display was exactly the same as the top page.
What I want to achieve is to display the user index.
I have created some User instances.

I wondered if the routing was suspicious,

users GET /users(.:format)


Is displayed, so I think there is no problem here.
There is no error, so I don't know what is wrong.
Could you give me some advice and hints
Thank you.

routes.rb

Rails.application.routes.draw do
  root to:'scores#index'
  resources :scores
 get'signup', to:'users#new'
  resources :users, only: [:index, :show, :new, :create]
end


user.rb

class User</pre>
<p>users_controller.rb</p>
<pre><code data-language="Ruby">class UsersController</pre><p>users/index.html.erb</p>
<pre><code data-language="erb"><%= render'users', users: @users %>

users/_users.html.erb

<% if users.any? %><ul><% users.each do |user| %>  <li>                                  <%= user.name %>                            <p><%= link_to'View profile', user_path(user) %></p>                    </li><% end %></ul><%= paginate users %><% end %>
module UsersHelper
  def gravatar_url(user, options = {size: 80 })
    gravatar_id = Digest::MD5::hexdigest(user.email.downcase)
    size = options[:size]
    "https://secure.gravatar.com/avatar/#{gravatar_id}?s=#{size}"
  end
end


scores/index.html.etb

Scorecard<ul><% @scores.each do |score| %>  <li><%= score.id %>H: Par<%= score.par %><%= link_to score.hole_score ,score %><%= score.hole_score-score.par %></li><% end %></ul><p>Today's score is
  <%= @total_score %></p>    Welcome to the Microposts  <%= link_to'Sign up now!', signup_path, class:'btn btn-lg btn-primary' %>


scores_controller.rb

class ScoresController
  • Answer # 1

    Although the cause is unknown, it is now displayed.
    If you don't see it, look at the log first.

Related articles