Skip to content

Instantly share code, notes, and snippets.

View jessewaites's full-sized avatar

Jesse Waites jessewaites

View GitHub Profile
@jessewaites
jessewaites / gist:ff057097328b823251b3976117404934
Created October 26, 2017 18:34
Link To External Page in React Router
<BrowserRouter>
<div>
<Match exactly pattern="/google" component={() => window.location = 'http://google.com'} />
<Match pattern="/store/:storeId" component={App} />
<Miss component={NotFound} />
</div>
</BrowserRouter>
def create
if @thing.save
redirect_to thing_form_path(@thing), notice: "You saved the thing!"
else
flash[:error] = @thing.errors.full_messages.to_sentence
render :new
end
end
class ReportCardMailer < ActionMailer
def report(user)
@user = user
@report_card = user.report_cards.last
options = {
to: @user.email,
from: "admin@yoursite.com",
subject: "Your Report Card for "@report_card.report_start_time.strftime("%b %d, %Y")" to
@jessewaites
jessewaites / gist:e5ccf9ab8ac7c71f45cf1ca6064d8091
Created April 22, 2016 17:44
Rails Flash Messages for Zurb Foundation 5+
<!-- Rails flash messages styled for Zurb Foundation. -->
<!-- Activate with flash.message = "X", flash.alert = "Y" -->
<% flash.each do |name, msg| %>
<% if msg.is_a?(String) %>
<div data-alert style="text-align" class="alert-box <%= name.to_s == 'notice' ? 'success' : 'alert' %>">
<%= content_tag :div, msg %>
<a href="#" class="close">&times;</a>
</div>
<% end %>
<% end %>
<head>
<!-- other stuff in your site header like javascript or whatever above here -->
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="@your_twitter_handle">
<meta name="twitter:creator" content="@your_twitter_handle">
<!-- hardcoding an image here so I don't have to worry about attaching an image to each blog post in the future -->
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')
=========================================================
I am a subscriber
I want to view full articles
So that I can get convenient access to the news
---------------------------------------------------------
Subscriber Acceptance Requirements:
-Subscriber logs in system recognizes him as a subscriber allows full access to articles
=========================================================
I am a non-subscriber
I want to preview the article and be able to subscribe
User Stories HW
"As a ______, I want to _____ so I can _____."
As any visitor, I want to see orderly article layout so I can decide what to read.
As a premium subscriber, I want to easily see the premium so I can feel like I am getting my moneys worth.
As a premium subscriber, I want to see fewer ads so I can concentrate on and enjoy the content I paid for.
As a free visitor, I want to see prominent "membership" opportunities so I can become a paying member if I decide.
chris@luna ~ (master*) $ telnet localhost 8080
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
GET /?name=Chris HTTP/1.0
HTTP/1.1 200 OK
Content-Type: text/html
Server: WEBrick/1.3.1 (Ruby/1.9.3/2012-11-10)
Date: Sat, 13 Apr 2013 00:07:11 GMT