This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ActiveRecord::Schema.define(version: 20131006225214) do | |
create_table "matches", force: true do |t| | |
t.integer "result" | |
t.boolean "checked_out", default: false | |
t.boolean "repeated", default: false | |
t.boolean "planned", default: true | |
t.integer "round" | |
t.datetime "created_at" | |
t.datetime "updated_at" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def create | |
@user = User.find(params[:user_id]) | |
@stock = Stock.find_or_create_by_ticker(params[:ticker]) | |
@user.stocks << @stock | |
respond_with @stock | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Parameters: {"title"=>"This should do it", "sub_categorisations_attributes"=>[{"sub_category_id"=>3}, {"sub_category_id"=>4}], "product"=>{"title"=>"This should do it"}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## app/views/layouts/application.html.erb | |
<!DOCTYPE html> | |
<html> | |
<head> | |
<% if current_user.admin? %> | |
<%= stylesheet_link_tag 'application_admin' %> | |
<% else %> | |
<%= stylesheet_link_tag 'application_nonadmin' %> | |
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filters = {} | |
filters[:name] = params[:name] if params[:name] | |
filters[:age] = params[:age] if params[:age] | |
filters[:gender] = params[:gender] if params[:gender] | |
# or some computation or other process for each field here instead, to mimic functionality that a simple slice wouldnt replicate | |
Person.where(filters) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ApplicationHelper | |
require 'asciidoctor' | |
def asciidoctor(text) | |
Asciidoctor.convert(text) | |
end | |
require 'coderay' | |
def coderay(text) | |
#I tried data-lang="( ... etc) since the browser output does that. |