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

Popular posts from this blog

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -