52
49

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Rails】link_toにparamsをもたせる方法

Posted at

View

<%= link_to "リンクです。", kobito_path, user_id: @user.id, user_name: @user.name %>

Controller

class QiitasController
  def kobito
    params[:user_id] #-> 3 
    params[:user_name] #-> "太郎"
  end
end

いくつでもparams持たせることが出来ます。

52
49
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
52
49

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?