こんばんは
Railsでviewを作成している時に、helperからlink_toを使いたい時って結構あるのではないかと思います。
やり方は簡単です。
module ExampleHelper
def example(word)
link_to word, 'https://www.google.co.jp/', target: "_blank"
end
end
これでhelperからlink_toが使えるようになりました。
– Bucket of cotegg –
投稿日:
こんばんは
Railsでviewを作成している時に、helperからlink_toを使いたい時って結構あるのではないかと思います。
やり方は簡単です。
module ExampleHelper
def example(word)
link_to word, 'https://www.google.co.jp/', target: "_blank"
end
end
これでhelperからlink_toが使えるようになりました。
執筆者:asakos
関連記事
ActiveRecord::Relationのklassメソッドでmodelを取得できる。
こんにちは。コーテッグのこやまです。 モデルに対してallやwhereメソッドを …
[Rails] モデルが初期化されてないとな(not initialized)
どうも中田です Railsで、modelの initialize に処理を追加す …
2020/05/31
【Angular】component.htmlをprettierで整形する
2020/05/24
【Angular】Full calendarで横スクロールを実装
2020/05/10
document.querySelectorで色々なDOMを取得する
2020/05/09
Quarantine Improvement: Creating Anything