Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View lelandsmith's full-sized avatar

Leland Smith lelandsmith

View GitHub Profile
Existing schema is below:
ActiveRecord::Schema.define(:version => 20120130161449) do
create_table "movies", :force => true do |t|
t.string "title"
t.string "rating"
t.text "description"
t.datetime "release_date"
t.datetime "created_at"
@lelandsmith
lelandsmith / Multiple checkboxes for ruby array
Last active December 9, 2022 18:55
Multiple checkboxes for ruby array
#MODEL
serialize :storage_type
#CONTROLLER
:storage_type => []
#FORM
#STORE = model
<div class="field">
@lelandsmith
lelandsmith / Input Select Box for Rails
Last active August 29, 2015 13:57
Input Select Box for Rails
<div class="field">
<%= f.label "Select Sub City" %>
<% new_york_sub_cities = %w(manhattan bronx kings queens staten) %>
<%= select("store", "city", new_york_sub_cities.collect {|p| [ p, p ] }, {include_blank: ''}) %>
</div>
@lelandsmith
lelandsmith / WP:Get the Categories
Created March 11, 2014 23:38
WP:Get the Categories
<?php $category = get_the_category();
if($category[0]){
echo '<a href="'.get_category_link($category[0]->term_id ).'">'.$category[0]->cat_name.'</a>';
} ?>
@lelandsmith
lelandsmith / gist:9497538
Created March 11, 2014 23:44
WP: Get the Tags
<?php
if(get_the_tag_list()) {
echo get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>
@lelandsmith
lelandsmith / gist:9497773
Created March 12, 2014 00:02
WP: limiting the_content
<?php echo wp_trim_words( get_the_content(), 35, "..." ); ?>
@lelandsmith
lelandsmith / gist:9497912
Created March 12, 2014 00:15
WP: Get Posts Query Loop
<?php
$args = array( 'numberposts' => 1, 'offset'=> 2, 'category' => 19 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h2 style="font-size: 26px;"><a href="<?php the_permalink(); ?>"> <?php the_title(); ?> </a></h2>
<?php the_time('F jS, Y') ?> | <?php the_author_link(); ?> | <a href="<?php the_permalink(); ?>/#respond" title=""><?php comments_number('0'); ?></a>
# This is a template .gitignore file for git-managed WordPress projects.
#
# Fact: you don't want WordPress core files, or your server-specific
# configuration files etc., in your project's repository. You just don't.
#
# Solution: stick this file up your repository root (which it assumes is
# also the WordPress root directory) and add exceptions for any plugins,
# themes, and other directories that should be under version control.
#
# See the comments below for more info on how to add exceptions for your