Skip to content

Instantly share code, notes, and snippets.

@kibaekr
Created November 24, 2012 22:50
Show Gist options
  • Save kibaekr/4141717 to your computer and use it in GitHub Desktop.
Save kibaekr/4141717 to your computer and use it in GitHub Desktop.
if condition doesn't catch show page.
view/layouts/tracks.html.erb
//according to the Layout Assignment on http://api.rubyonrails.org/classes/AbstractController/Layouts.html, I created a new layout file with the same name as the controller
<!DOCTYPE html>
<html>
<head>
<title><%= content_for?(:title) ? yield(:title) : "Onvard" %></title>
<!-- [if lt IE9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"
type ="text/javascript"></script>
<![endif]-->
<%= favicon_link_tag %>
<%= csrf_meta_tags %>
<meta name="viewport" content ="width=device-width, initial-scale=1.0">
<%= render 'layouts/stylesheets' %>
<script type="text/javascript">if (window.location.hash == '#_=_')window.location.hash = '';</script>
</head>
<body>
<%= render 'layouts/header' %>
<div class="background">
<!-- PROBLEM: if i include the show_track, then other pages dont work . -->
<%# elsif current_page?(:controller => 'tracks', :action => 'show') %>
<%#= yield :show_track %>
<%# else %>
<%= render 'layouts/flashes' %>
<% if current_page?(:controller => 'tracks', :action => 'show') %>
<%= yield :show_track %>
<% else %>
<div class="container_980 white shadow-horizontal">
<div class="container">
<%= render 'layouts/flashes' %>
<%= yield %>
</div>
</div>
<% end %>
<%# end %>
</div> <!-- end body class -->
<!-- FOOTER -->
<div class="footer">
Copyright &copy; 2012 Onvard |
<strong><%= link_to "About", about_path %></strong> |
<strong><%= link_to "Contact", contact_path %></strong> |
<strong><%= link_to "Leaderboard", leader_path %></strong>
<br />
<!--
<div class="fb-like" data-href="https://www.facebook.com/Onvard" data-send="false" data-width="400" data-show-faces="true" data-font="segoe ui">
</div> -->
</div>
</body>
<% debug(params) if Rails.env.development? %>
</html>
view/tracks/show.html.erb
<!-- stylesheet: track_show.css.scss -->
<% title @track.title %>
<% content_for :show_track do %>
<div class="track_header index_top_indent">
<div class="row container_980">
<div class="span2">
<div class="float-left">
<%= image_tag(@track.image_url(:featured), :size => "145x145") %>
</div>
</div>
<div class="">
<div class="row">
<div class="span6">
<h2><%= @track.title %></h2>
<div id="show_track_author">
<%= image_tag @profileimg unless @profileimg.blank? %>
<%= link_to @track.author.username, profile_path(@track.author) %>
</div>
</div>
<div class="span4">
<div id="track_show_info_box">
<div id="track_show_info_box_top">
<% if @track.users.include?(current_user) %>
<%= link_to 'Remove Bookmark', unbookmark_track_path(@track),
:method => :post, :class => 'btn btn-large'%>
<% else %>
<%= link_to 'Bookmark Track', bookmark_track_path(@track), :method => :post, :class => 'btn btn-success btn-large'%>
<% end %>
<%= link_to vote_for_track_track_path(@track), :method => :post, :class => 'btn' do %>
<i class="icon-thumbs-up"></i> Vote up
<% end %>
<%= link_to vote_against_track_track_path(@track), :method => :post, :class => 'btn' do %>
<i class="icon-thumbs-down"></i>
<% end %>
</div>
<div id="track_show_info_box_bottom">
<div id="stats">
<i class ="icon-fire"></i> <%= @track.difficulty.downcase %> level
<i class ="icon-time"></i> created <%= time_ago_in_words(@track.created_at) + " ago"%> <br />
<i class ="icon-arrow-up"></i> <%= @track.karma %> votes
<i class ="icon-star"></i> <%= @track.users.count %> bookmarked
<i class ="icon-eye-open"></i> <%= @track.hits %> views
</div>
</div>
</div>
</div>
</div> <!-- end nested row -->
<br />
<div class="row">
<div class="span12 dialog-box">
<%= @track.description %>
<b> have option to click and hide after read</b>
</div>
</div> <!-- end nested row -->
</div><!-- end right side of track pic -->
</div>
</div>
<!-- end track_header -->
<!-- MISSIONS BELOW -->
<div class="container_980">
<div class="container">
<div class="row">
<div class="span9">
<!-- this is where missions will go -->
<div class="well">
<h2> Work through the "Try Ruby" exercises</h2>
Many people give up learning RoR because they think they have to master Ruby. This is not true, so don't worry! You do not have to fully dominate the Ruby language to learn and enjoy Rails. You just need the basics to begin.
Go through the exercises in Try Ruby (will take roughly 30 minutes)
You'll be greeted with an interactive screen where you can follow along the few exercises. Just try it to get a sense of what the language is like and a feel for the syntax.
(You can also check out 'Learn Ruby the Hard Way' if you really want to master the language, but just diving into rails and learning as you go will be more fun!)
</div>
</div>
<div class="span3">
social media share buttons <br />
detailed author info <br />
tags
</div>
</div>
</div>
<div class="form-actions">
<%= link_to 'Back', tracks_path, class: 'btn' %>
<% if (@track.author == current_user) || ((user_signed_in?) && (current_user.admin == true)) %>
<%= link_to 'Edit', edit_track_path(@track), class: 'btn' %>
<%= link_to 'Destroy', @track, confirm: 'Are you sure?', method: :delete, class: 'btn btn-danger float-right' %>
<% end %>
</div>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment