Skip to content

Instantly share code, notes, and snippets.

Avatar

Leland Smith lelandsmith

View GitHub Profile
View gist:9103703
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"
View creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
View creating-nested-resources-in-ruby-on-rails-3-and-updating-scaffolding-links-and-redirection.markdown
@lelandsmith
lelandsmith / Multiple checkboxes for ruby array
Last active Aug 29, 2015
Multiple checkboxes for ruby array
View 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 Aug 29, 2015
Input Select Box for Rails
View 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>
View 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>';
} ?>
View gist:9497538
<?php
if(get_the_tag_list()) {
echo get_the_tag_list('<ul><li>','</li><li>','</li></ul>');
}
?>
@lelandsmith
lelandsmith / gist:9497773
Created Mar 12, 2014
WP: limiting the_content
View gist:9497773
<?php echo wp_trim_words( get_the_content(), 35, "..." ); ?>
@lelandsmith
lelandsmith / gist:9497912
Created Mar 12, 2014
WP: Get Posts Query Loop
View gist:9497912
<?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>
View .gitignore WP
# 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
You can’t perform that action at this time.