Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View andrebautista's full-sized avatar

Andre Bautista andrebautista

View GitHub Profile
@andrebautista
andrebautista / redux question
Created November 3, 2017 15:28
updating nested properties based on an action property
//reducer.js
initState = {
foo: {
value_a: "",
value_b: ""
},
bar: {
value_a: "",
value_b: ""
=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')
@andrebautista
andrebautista / gist:9523433
Last active August 29, 2015 13:57
Using retina image - example css code
@media only screen and (-webkit-min-device-pixel-ratio: 1.5),
only screen and (min-device-pixel-ration: 1.5) {
body {
background-image: url(subtle_dots_@2X.png);
}
}
$(document).ready(function () {
$("small.error").each(function(){
(this).closest("input").addClass("error");
});
});
<input class="string email optional" id="contact_form_email" name="contact_form[email]" size="50" type="email" value="fdsfs">
<small class="error">is invalid</small>
When I first started my journey into rails I had no practice with HTML or CSS, and was looking
to try out the skills I had gained from Team Treehouse and various books. I started the Michael
Hartl Rails tutorial and about 4 chapters in I got to a point where I could build my first website.
Despite the fact I wasn’t harnessing the power of Rails and it’s RESTful routes, which makes creating,
updating and destroying a record of the database a simple task, I was gaining valuable skills that will
now allow me to create nice, user friendly web apps. I then realized that until you start going through
the motions and actually apply the knowledge you’ve learned through books and online tutorials, it’s
hard to retain any of it. So I’m going to break down what I learned in the Hartl tutorial and walk you
through the steps to create a static website “sandbox” to test out HTML and CSS.
The first thing you’ll need to do is get Rails installed on your computer, refer to section 1.2.2 'Ruby,
<script>
var $btn2 = $('.info-pop');
$btn2.popover({trigger: 'hover'})
.one('click', function() {
$btn2.popover('destroy')
.popover({ trigger: 'click'})
.popover('show');
});
</script>
class PostsController < ApplicationController
before_filter :authenticate_user!, except: [:index, :show]
# GET /posts
# GET /posts.json
def index
@posts = policy_scope(Post)
respond_to do |format|
format.html # index.html.erb
class Comment < ActiveRecord::Base
belongs_to :commentable, polymorphic: true
validates :content, presence: true
validates :author_email, presence: true
validates :author, presence: true
end
class Project < ActiveRecord::Base
attr_accessible :name, :technologies_used
validates :technologies_used, presence: true