This file contains hidden or 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 CreateCategories < ActiveRecord::Migration | |
| def self.up | |
| create_table :categories do |t| | |
| t.string :name_en, | |
| :name_cz, | |
| :name_es | |
| t.timestamps | |
| end | |
| end | |
This file contains hidden or 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
| locales = ["cz", "en"] | |
| %w{name name_cz name_is_long name_is_long_cz name123_cz name_en name_ane name_es}.each do |attribute_name| | |
| if includes_locale = locales.find { |locale| attribute_name =~ Regexp.new("_#{locale}$") } | |
| puts includes_locale.inspect | |
| puts attribute_name + ' : true' | |
This file contains hidden or 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
| <tr> | |
| <td style="width: 25%" class="align-right sortable"><%= text_field_tag 'program_event[entrance_fees][][price]', nil, :class => 's' %> Kč</td> | |
| <td style="width: 50%" class="sortable"> | |
| <!-- <span class="drag_handle"> </span> --> | |
| <%= text_field_tag 'program_event[entrance_fees][][description]', nil %> | |
| </td> | |
| <td> </td> | |
| </tr> | |
This file contains hidden or 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
| >> Dir.pwd | |
| => "/Users/karmi/Playground/Ruby/Pushr/Application/shared/cached-copy" | |
| >> | |
| >> `git status` | |
| => "# On branch master\nnothing to commit (working directory clean)\n" | |
| >> | |
| >> `git fetch -q nonexistent` | |
| fatal: 'nonexistent': unable to chdir or not a git archive | |
| fatal: The remote end hung up unexpectedly | |
| => "" |
This file contains hidden or 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
| >> Dir.pwd | |
| => "/Users/karmi/Playground/Ruby/Pushr/Application/shared/cached-copy" | |
| >> | |
| >> `git status` | |
| => "# On branch master\nnothing to commit (working directory clean)\n" | |
| >> | |
| >> `git fetch -q nonexistent 2>&1` | |
| fatal: 'nonexistent': unable to chdir or not a git archive | |
| fatal: The remote end hung up unexpectedly | |
| => "" |
This file contains hidden or 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 SheepInYourShoes | |
| # The Pasture | |
| class Pasture | |
| attr_reader :sheep, :dog, :catched | |
| def initialize(num_sheep=0) | |
| @catched = 0 | |
| @sheep = [] |
This file contains hidden or 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
| == Usage | |
| Declare the association in your ActiveRecord model: | |
| picturable_with_flickr | |
| You can then attach/access/destroy your pictures (assuming there's a model +Book+ in your application): | |
| Picturable.search( :text => 'My cute kitten' ) | |
| => #<Flickr::Photos::PhotoResponse:0x300dc5c ... photos[#<Flickr::Photos::Photo:0x2fe6a30 ... @id="1234567890", ... |
This file contains hidden or 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
| == Usage | |
| Declare the association in your ActiveRecord model: | |
| picturable_with_flickr | |
| You can then attach/access/destroy your pictures (assuming there's a model +Book+ in your application): | |
| Picturable.search( :text => 'My cute kitten' ) | |
| => #<Flickr::Photos::PhotoResponse:0x300dc5c ... photos[#<Flickr::Photos::Photo:0x2fe6a30 ... @id="1234567890", ... |
This file contains hidden or 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
| Let's make a list of Sinatra-based apps! | |
| Apps: | |
| - http://github.com/cschneid/irclogger "Sinatra based irclogger.com" | |
| - http://github.com/rtomayko/wink "minimalist blogging engine" | |
| - http://github.com/foca/integrity "The easy and fun Continuous Integration server" | |
| - http://github.com/sr/git-wiki "git-powered wiki" | |
| - http://github.com/entp/seinfeld "Seinfeld-inspired productivity calendar to track your public github commits." | |
| - http://github.com/karmi/marley "Marley, the blog engine without <textareas>." | |
| - http://github.com/ichverstehe/gaze "Serve up your Markdown files with this tiny Sinatra app!" |
This file contains hidden or 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
| # Find all records tagged with a +'tag'+ or ['tag one', 'tag two'] | |
| # Pass either String for single tag or Array for multiple tags | |
| def find_all_tagged_with(tag_or_tags) | |
| case tag_or_tags | |
| when Array | |
| all(:include => ['tags', 'taggings']).select { |record| tag_or_tags.all? { |tag| record.tags.map(&:name).include?(tag) } } | |
| when String | |
| all(:include => ['tags', 'taggings']).select { |record| record.tags.map(&:name).include?(tag_or_tags) } | |
| end | |
| end |