refactor: improve conditional rendering in views
- Replace 'else' with 'elsif' for better clarity - Ensure badges are displayed only when country and state are present These changes enhance the readability of the code and ensure that only relevant information is displayed in the UI, improving the user experience.
This commit is contained in:
parent
5b7f0bba4f
commit
639c36200b
@ -35,7 +35,7 @@
|
|||||||
<%= link_to cities_path(country: @city.country, region: @city.country.region), class: "badge badge-lg badge-primary hover:badge-outline transition-all duration-200" do %>
|
<%= link_to cities_path(country: @city.country, region: @city.country.region), class: "badge badge-lg badge-primary hover:badge-outline transition-all duration-200" do %>
|
||||||
<%= "#{@city.country.emoji + " " || ""}#{@city.country.localized_name}" %>
|
<%= "#{@city.country.emoji + " " || ""}#{@city.country.localized_name}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% elsif @city.country.present? %>
|
||||||
<div class="badge badge-lg badge-primary">
|
<div class="badge badge-lg badge-primary">
|
||||||
<%= "#{@city&.country&.emoji + " " || ""}#{@city&.country&.localized_name}" %>
|
<%= "#{@city&.country&.emoji + " " || ""}#{@city&.country&.localized_name}" %>
|
||||||
</div>
|
</div>
|
||||||
@ -45,7 +45,7 @@
|
|||||||
<%= link_to cities_path(country: @city.country, state: @city.state, region: @city.country.region), class: "badge badge-lg badge-secondary hover:badge-outline transition-all duration-200" do %>
|
<%= link_to cities_path(country: @city.country, state: @city.state, region: @city.country.region), class: "badge badge-lg badge-secondary hover:badge-outline transition-all duration-200" do %>
|
||||||
<%= @city.state.name %>
|
<%= @city.state.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% elsif @city.state.name.present? %>
|
||||||
<div class="badge badge-lg badge-secondary">
|
<div class="badge badge-lg badge-secondary">
|
||||||
<%= @city&.state&.name %>
|
<%= @city&.state&.name %>
|
||||||
</div>
|
</div>
|
||||||
|
@ -27,7 +27,7 @@
|
|||||||
<%= link_to cities_path(country: @weather_art.city.country, region: @weather_art.city.country.region), class: "badge badge-lg badge-primary hover:badge-outline transition-all duration-200" do %>
|
<%= link_to cities_path(country: @weather_art.city.country, region: @weather_art.city.country.region), class: "badge badge-lg badge-primary hover:badge-outline transition-all duration-200" do %>
|
||||||
<%= "#{@weather_art.city.country.emoji + " " || ""}#{@weather_art.city.country.localized_name}" %>
|
<%= "#{@weather_art.city.country.emoji + " " || ""}#{@weather_art.city.country.localized_name}" %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% elsif @weather_art.city.country.present? %>
|
||||||
<div class="badge badge-lg badge-primary">
|
<div class="badge badge-lg badge-primary">
|
||||||
<%= "#{@weather_art&.city&.country&.emoji + " " || ""}#{@city&.country&.localized_name}" %>
|
<%= "#{@weather_art&.city&.country&.emoji + " " || ""}#{@city&.country&.localized_name}" %>
|
||||||
</div>
|
</div>
|
||||||
@ -37,7 +37,7 @@
|
|||||||
<%= link_to cities_path(country: @weather_art.city.country, state: @weather_art.city.state, region: @weather_art.city.country.region), class: "badge badge-lg badge-secondary hover:badge-outline transition-all duration-200" do %>
|
<%= link_to cities_path(country: @weather_art.city.country, state: @weather_art.city.state, region: @weather_art.city.country.region), class: "badge badge-lg badge-secondary hover:badge-outline transition-all duration-200" do %>
|
||||||
<%= @weather_art.city.state.name %>
|
<%= @weather_art.city.state.name %>
|
||||||
<% end %>
|
<% end %>
|
||||||
<% else %>
|
<% elsif @weather_art.city.state.name.present? %>
|
||||||
<div class="badge badge-lg badge-secondary">
|
<div class="badge badge-lg badge-secondary">
|
||||||
<%= @weather_art&.city&.state&.name %>
|
<%= @weather_art&.city&.state&.name %>
|
||||||
</div>
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user