Put a link in a flash[:notice]

后端 未结 8 1479
天涯浪人
天涯浪人 2020-12-04 23:31

I am learning Ruby and Rails.

I have a Ruby on Rails project that tracks jobs a server is running. Right now, when I manually create a new job, it announces:

<
8条回答
  •  自闭症患者
    2020-12-05 00:26

    As nas commented, link_to is not available from your controller unless you include the appropriate helper module, but url_for is. Therefore I'd do pretty much what Emily said except use url_for instead of hardcoding a URL.

    e.g. if a job were defined as a resource in your routes:

    link = "#{update.id}"    
    flash[:notice] = "Created job number #{link}"
    

提交回复
热议问题