Skip to content

Commit 3e28bd5

Browse files
committed
refactor: ハードコーディングされたパスをRailsヘルパーに置き換え
Rails Wayに従い、以下の改善を実施: 1. ハードコーディングされたパスをパスヘルパーに変更 - /signup → signup_path - /stats → stats_path - /english/stats → english_stats_path - /dojos → dojos_path - /english → english_path - /docs → docs_path 2. HTML特殊文字を含むリンクには raw() ヘルパーを使用 - » (») や « («) を正しく表示 - .html_safe より意図が明確で安全性の確認がしやすい 3. 掲載日アイコンを 🗓 から 🗾 に変更 - 開催日(🗓)と視覚的に区別可能に これにより、ルート変更時の自動追従、タイポ防止、IDE補完が可能になり、 コードの保守性とRails規約への準拠が向上しました。
1 parent 27cbd1e commit 3e28bd5

File tree

5 files changed

+11
-15
lines changed

5 files changed

+11
-15
lines changed

app/views/docs/show.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414

1515
<% if request.path.start_with? '/docs' %>
1616
<div style="margin-bottom: 40px;">
17-
<p style="color: #5F5F5F"><small><a href='/docs'>&laquo; 資料一覧に戻る</a></small></p>
17+
<p style="color: #5F5F5F"><small><%= link_to raw('&laquo; 資料一覧に戻る'), docs_path %></small></p>
1818
</div>
1919
<% end %>
2020

app/views/dojos/activity.html.erb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
<br />
1414
<p style="margin: 0 0px 40px 10px; line-height: 1.5em;">
1515
主にデータ分析や
16-
<a href="/signup#terms-of-use">Active/Inactive</a>
16+
<%= link_to 'Active/Inactive', signup_path(anchor: 'terms-of-use') %>
1717
の判断などの用途で使われています。
1818
<br>
1919
<div class='form__terms list'>
@@ -37,9 +37,9 @@
3737
</th>
3838
<th>
3939
<small>
40-
🗓
40+
🗾
4141
<br class='ignore-pc'>
42-
<a href='/signup'>掲載日</a>
42+
<%= link_to '掲載日', signup_path %>
4343
</small>
4444
</th>
4545
<th>

app/views/dojos/index.html.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@
2424
</ul>
2525
</div>
2626
<div style="text-align: center; margin-top: 10px; margin-bottom: 50px;">
27-
<a href="/stats" style="color: #007bff; text-decoration: none;">
28-
&raquo; 推移グラフで見る
29-
</a>
27+
<%= link_to raw('&raquo; 推移グラフで見る'), stats_path, style: 'color: #007bff; text-decoration: none;' %>
3028
</div>
3129
</p>
3230

@@ -74,9 +72,9 @@
7472
</th>
7573
<th>
7674
<small>
77-
🗓
75+
🗾
7876
<br class='ignore-pc'>
79-
<a href='/signup'>掲載日</a>
77+
<%= link_to '掲載日', signup_path %>
8078
</small>
8179
</th>
8280
<th>

app/views/events/index.html.erb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
<p style="margin: 0 30px 40px 0px; line-height: 2.0em;">
1515
☯️ 開催予定のイベントをチェックしよう!
1616
<br>
17-
(🗾<a href="<%= dojomap_url %>">地図から探す</a>
17+
(🗾 <%= link_to '地図から探す', dojomap_url %>
1818
/ 🗓 <a href="https://bit.ly/coderdojo-calendar-by-each-region">カレンダー連携</a>
1919
</p>
2020

app/views/stats/show.html.erb

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@
2323
</div>
2424
<div style="margin-top: 20px;">
2525
<% if @lang == 'en' %>
26-
<a href="/stats">&raquo; Switch to Japanese</a>
26+
<%= link_to raw('&raquo; Switch to Japanese'), stats_path %>
2727
<% else %>
28-
<a href="/english/stats">&raquo; View in English</a> / <a href="/dojos">&raquo; 年次データを見る</a>
28+
<%= link_to raw('&raquo; View in English'), english_stats_path %> / <%= link_to raw('&raquo; 年次データを見る'), dojos_path %>
2929
<% end %>
3030
</div>
3131

@@ -399,9 +399,7 @@
399399
<% if @lang == 'en' %>
400400
<ul>
401401
<li>
402-
<a href="/english">
403-
&raquo; See CoderDojo Japan Association history
404-
</a>
402+
<%= link_to raw('&raquo; See CoderDojo Japan Association history'), english_path %>
405403
</li>
406404
<li>
407405
<a href="https://www.youtube.com/playlist?list=PL94GDfaSQTmKxMzXVMzzdl-zCmzgitQFP">

0 commit comments

Comments
 (0)