# MyApp/app/models/blorgh/post.rb
# overrides Blorgh's original Post model
class Blorgh::Post < ActiveRecord::Base
include Blorgh::Concerns::Models::Post
def time_since_created
Time.current - created_at
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
# example take from | |
# https://github.com/schneems/wicked/blob/40443aea2aba0fe506b9c878fb677f08f2114200/lib/wicked/wizard.rb | |
require 'active_support/concerns' | |
module FooBar::Concerns::Controllers::OneController | |
extend ActiveSupport::Concerns | |
# controller level methods associated with a Rails-route and View | |
# IE, the controller structure |
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
lasdjflksdajfklj |
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
# want to see module/classes referenced via symbols. | |
# put this into IRB | |
module M # Main is 3 keys longer than M | |
class A | |
def test | |
"a" | |
end | |
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
> mongo | |
// saving records | |
db.test.save({"a": 1}) // | |
db.test.find() // { "_id" : ObjectId("502437b4a1d603739ab59206"), "a" : 1 } | |
db.test.save({"a": 100}) // | |
// retreaving range of records | |
db.test.find( { "a": { $gt: 0, $lt: 500 } } ) // { "_id" : ObjectId("502437b4a1d603739ab59206"), "a" : 1 } | |
// { "_id" : ObjectId("502675b7792a4a17c3b470b6"), "a" : 100 } |
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
class Tweet | |
attr_accessor :status | |
attr_reader :created_at | |
def initialize(status) | |
@status = status | |
@created_at = Time.now | |
end | |
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
app1 | |
|- app/views/photo_contests | |
| |- index.html.erb # => custom view template #1 | |
| | |
\- Gemfile (gem 'common_engine') | |
app2 | |
|- app/views/photo_contests | |
| |- index.html.erb # => custom view template #2 | |
| |
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
# This spec fails when I run it for (JRuby + sqlite), but not (Ruby 1.9.3 + [mysql | postgres]) | |
# | |
# some_model.rb | |
describe SomeModel | |
it { should have_db_index(:name).unique(true) } | |
end | |
# Even though the schema.rb shows the db field as unquiely indexed. | |
# |
command line UI.
psql -h localhost
other helpful commands
\du list users
CREATE DATABASE db_name;
CREATE ROLE postgres;
OlderNewer