简体   繁体   中英

Ruby - how to correctly pass an object as parameter and then display it

I am passing an object like this:

-@users.each do |user|
          %tr
            %td=link_to(user.first_name, users_user_path(user), :title => user.first_name)
            %td=user.first_name

but I am not exactly sure how to retrieve the user object in the controller. I try something like this:

user = User.new(params[:@user])
@user = params[:@user]

But nothing like that works. How is this supposed to work?

Thanks!

您已经接近..要使用户进入控制器,您可以这样做:

@user = User.new(params[:user])

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM