How to use params for user dashboard in rails -
i have question params:
how filter display of each user in controller.
in model
user.rb: has_many: questions
question.rb belongs_to: user
controller:
` skip_before_action :authenticate_user!, only: [ :new ] before_action :find_question, only: [:show, :edit, :update, :destroy]
def index @questions = questions.all end private def find_question @question = question.find(params[:id]) end`
it's ok
my solution realy simple....
create users_controller with:
class userscontroller < applicationcontroller def show @user = user.find(params[:id]) @questions = @user.questions end end
and
users.html.erb with:
<% @questions.each |question| %> bla,bla,bla,bla <% end %>
thanks time.
Comments
Post a Comment